T34: prompts and commands carry OSC 133 marks: the tap reads every OSC body and hands 133's marks to the session, which keeps its last command's status; zsh, bash, fish and PowerShell mark what the shell leaves unmarked, and the user's prompt still sees the status
This commit is contained in:
18 files changed
+359
-88
No files matched your search
@@ -1,4 +1,4 @@
|
||||
# ELYTerminal: restore XDG_DATA_DIRS, report the folder; fish_title keeps the title.
|
||||
# ELYTerminal: restore XDG_DATA_DIRS, report the folder, mark what this fish leaves unmarked; fish_title keeps the title.
|
||||
if test -n "$ELY_FISH_XDG_DATA_DIRS"
|
||||
set -gx XDG_DATA_DIRS $ELY_FISH_XDG_DATA_DIRS
|
||||
else
|
||||
@@ -9,4 +9,33 @@ if status is-interactive
|
||||
function _ely_prompt --on-event fish_prompt
|
||||
printf '\e]7;file://%s\a' (string escape --style=url -- $PWD)
|
||||
end
|
||||
# fish 4.3 marks its own prompts and commands; 4.0 all but the prompt's end; older ones none.
|
||||
set -l v (string split ' ' -- (string replace -r '^(\d+)\.(\d+).*' '$1 $2' -- $version))
|
||||
if test $v[1] -lt 4
|
||||
set -g _ely_marks A B
|
||||
function _ely_preexec --on-event fish_preexec
|
||||
printf '\e]133;C\a'
|
||||
end
|
||||
function _ely_postexec --on-event fish_postexec
|
||||
printf '\e]133;D;%s\a' $status
|
||||
end
|
||||
else if test $v[1] -eq 4 -a $v[2] -lt 3
|
||||
set -g _ely_marks B
|
||||
end
|
||||
if set -q _ely_marks
|
||||
# The user's prompt loads late and may change; the marks go around the one shown.
|
||||
function _ely_wrap --on-event fish_prompt
|
||||
if functions -q _ely_user_prompt; and string match -q '*_ely_user_prompt*' -- (functions fish_prompt)
|
||||
return
|
||||
end
|
||||
functions -q _ely_user_prompt; and functions -e _ely_user_prompt
|
||||
functions -c fish_prompt _ely_user_prompt
|
||||
function fish_prompt
|
||||
# First, so the user's prompt sees the command's status.
|
||||
set -l text (_ely_user_prompt | string collect -N)
|
||||
contains A $_ely_marks; and printf '\e]133;A\a'
|
||||
printf '%s\e]133;B\a' "$text"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user