mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-01-08 22:33:20 +00:00
input configuration to pass input as stdin on startup
This adds a new configuration `input` that allows passing either raw text or file contents as stdin when starting the terminal. The input is sent byte-for-byte to the terminal, so control characters such as `\n` will be interpreted by the shell and can be used to run programs in the context of the loaded shell. Example: `ghostty --input="hello, world\n"` will start the your default shell, run `echo hello, world`, and then show the prompt.
This commit is contained in:
@@ -146,6 +146,8 @@ pub fn threadMain(self: *Thread, io: *termio.Termio) void {
|
||||
// have "OpenptyFailed".
|
||||
const Err = @TypeOf(err) || error{
|
||||
OpenptyFailed,
|
||||
InputNotFound,
|
||||
InputFailed,
|
||||
};
|
||||
|
||||
switch (@as(Err, @errorCast(err))) {
|
||||
@@ -165,6 +167,24 @@ pub fn threadMain(self: *Thread, io: *termio.Termio) void {
|
||||
t.printString(str) catch {};
|
||||
},
|
||||
|
||||
error.InputNotFound,
|
||||
error.InputFailed,
|
||||
=> {
|
||||
const str =
|
||||
\\A configured `input` path was not found, was not readable,
|
||||
\\was too large, or the underlying pty failed to accept
|
||||
\\the write.
|
||||
\\
|
||||
\\Ghostty can't continue since it can't guarantee that
|
||||
\\initial terminal state will be as desired. Please review
|
||||
\\the value of `input` in your configuration file and
|
||||
\\ensure that all the path values exist and are readable.
|
||||
;
|
||||
|
||||
t.eraseDisplay(.complete, false);
|
||||
t.printString(str) catch {};
|
||||
},
|
||||
|
||||
else => {
|
||||
const str = std.fmt.allocPrint(
|
||||
alloc,
|
||||
|
||||
Reference in New Issue
Block a user