From 6f7beca8d27e2e00f7b90bb75015637a9aa4c950 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 27 Sep 2026 18:07:06 -0300 Subject: Run a line at a terminal's prompt through pty/run and read how it ended /pane//pty/run takes factotum's rpc shape: write one line on an open, read the answer on that same open. The answer is exit N once the command ended and the shell is back at a prompt; busy at once when a command runs, text is typed at the prompt, or the shell has not drawn its first prompt; error not run when the shell refused the line without running it (fish on a syntax error keeps it on the prompt, so it is taken back with Ctrl-U); error shell gone when the pane closes or its shell is replaced; error no prompt marks for a shell pardes could not instrument. The end comes from the shell's OSC 133 marks. ghostty parses D's exit status and drops it, so the stream now runs through a handler that wraps ghostty's and follows prompt -> input -> running -> done. The marks pardes injects into bash and fish carry aid=pardes and only those count, so fish 4's own marks (which doubled ours), a nested shell's, and a stray 133;D in printed output are ignored. Checked end to end against real bash and fish: false, exit 7, a syntax error, sleep, busy while running, and the pane closing mid-command. Co-Authored-By: Claude Opus 5.5 --- src/host_io.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/host_io.zig') diff --git a/src/host_io.zig b/src/host_io.zig index f0a8d637..fcd2225b 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -588,9 +588,9 @@ pub const Shell = struct { const bash_rc = \\[ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc" - \\PS1='\[\e]133;A;cl=line\a\]'"$PS1"'\[\e]133;B\a\]' - \\PROMPT_COMMAND='printf "\e]133;D;%s\a" "$?"'"${PROMPT_COMMAND:+;$PROMPT_COMMAND}" - \\trap 'printf "\e]133;C\a"' DEBUG + \\PS1='\[\e]133;A;cl=line;aid=pardes\a\]'"$PS1"'\[\e]133;B;aid=pardes\a\]' + \\PROMPT_COMMAND='printf "\e]133;D;%s;aid=pardes\a" "$?"'"${PROMPT_COMMAND:+;$PROMPT_COMMAND}" + \\trap 'printf "\e]133;C;aid=pardes\a"' DEBUG \\ ; @@ -598,15 +598,15 @@ pub const Shell = struct { const fish_rc = \\functions -c fish_prompt __pardes_user_prompt \\function fish_prompt - \\ printf '\e]133;A;cl=line\a' + \\ printf '\e]133;A;cl=line;aid=pardes\a' \\ __pardes_user_prompt - \\ printf '\e]133;B\a' + \\ printf '\e]133;B;aid=pardes\a' \\end \\function __pardes_preexec --on-event fish_preexec - \\ printf '\e]133;C\a' + \\ printf '\e]133;C;aid=pardes\a' \\end \\function __pardes_postexec --on-event fish_postexec - \\ printf '\e]133;D;%s\a' $status + \\ printf '\e]133;D;%s;aid=pardes\a' $status \\end \\ ; -- cgit v1.3