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 ZDOTDIR, load the user's .zshenv, report folder and title.
|
||||
# ELYTerminal: restore ZDOTDIR, load the user's .zshenv, report folder and title, mark prompts and commands.
|
||||
if [[ -n "${ELY_ZSH_ZDOTDIR+set}" ]]; then
|
||||
ZDOTDIR=$ELY_ZSH_ZDOTDIR
|
||||
builtin unset ELY_ZSH_ZDOTDIR
|
||||
@@ -7,8 +7,13 @@ else
|
||||
fi
|
||||
[[ -r "${ZDOTDIR:-$HOME}/.zshenv" ]] && builtin source "${ZDOTDIR:-$HOME}/.zshenv"
|
||||
if [[ -o interactive ]]; then
|
||||
_ely_ran=
|
||||
_ely_precmd() {
|
||||
builtin local ret=$? LC_ALL=C char url=
|
||||
if [[ -n $_ely_ran ]]; then
|
||||
builtin printf '\e]133;D;%s\a' $ret
|
||||
_ely_ran=
|
||||
fi
|
||||
for char in ${(s::)PWD}; do
|
||||
case $char in
|
||||
[[:cntrl:]]|%) builtin printf -v char '%%%02X' "'$char" ;;
|
||||
@@ -16,12 +21,21 @@ if [[ -o interactive ]]; then
|
||||
url+=$char
|
||||
done
|
||||
builtin printf '\e]7;file://%s\a\e]2;%s\a' "$url" "${${${PWD:t}:-/}//[[:cntrl:]]/}"
|
||||
# Themes set PS1 in later hooks; from the next prompt the marks go on after them.
|
||||
precmd_functions=(${precmd_functions:#_ely_mark} _ely_mark)
|
||||
builtin return ret
|
||||
}
|
||||
_ely_mark() {
|
||||
if [[ -o prompt_percent && $PS1 != *$'\e]133;A'* ]]; then
|
||||
PS1=$'%{\e]133;A\a%}'$PS1$'%{\e]133;B\a%}'
|
||||
fi
|
||||
}
|
||||
_ely_preexec() {
|
||||
builtin printf '\e]2;%s\a' "${1//[[:cntrl:]]/}"
|
||||
_ely_ran=1
|
||||
builtin printf '\e]133;C\a\e]2;%s\a' "${1//[[:cntrl:]]/}"
|
||||
}
|
||||
builtin autoload -Uz add-zsh-hook
|
||||
add-zsh-hook precmd _ely_precmd
|
||||
add-zsh-hook precmd _ely_mark
|
||||
add-zsh-hook preexec _ely_preexec
|
||||
fi
|
||||
Reference in new issue
Block a user