Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/shell-integration/elvish/lib/ghostty-integration.elv
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
# List of enabled shell integration features
var features = [(str:split ',' $E:GHOSTTY_SHELL_FEATURES)]

# helper used by `mark-*` functions
# State tracking for semantic prompt sequences
# Values: 'prompt-start', 'pre-exec', 'post-exec'
fn set-prompt-state {|new| set-env __ghostty_prompt_state $new }

fn mark-prompt-start {
if (not-eq prompt-start (constantly $E:__ghostty_prompt_state)) {
printf "\e]133;D\a"
if (not-eq $E:__ghostty_prompt_state 'prompt-start') {
printf "\e]133;D;aid="$pid"\a"
}
set-prompt-state 'prompt-start'
printf "\e]133;A\a"
printf "\e]133;A;aid="$pid"\a"
}

fn mark-output-start {|_|
Expand All @@ -44,9 +45,15 @@
}
}

printf "\e]133;D;"$exit-status"\a"
printf "\e]133;D;"$exit-status";aid="$pid"\a"
}

# NOTE: OSC 133;B (end of prompt, start of input) cannot be reliably
# implemented at the script level in Elvish. The prompt function's output is
# escaped, and writing to /dev/tty has timing issues because Elvish renders
# its prompts on a background thread. Full semantic prompt support requires a
# native implementation: https://github.com/elves/elvish/pull/1917

fn sudo-with-terminfo {|@args|
var sudoedit = $false
for arg $args {
Expand Down
Loading