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: load the usual startup files, report folder and title.
|
||||
# ELYTerminal: load the usual startup files, report folder and title, mark prompts and commands.
|
||||
if [ -n "${ELY_BASH_LOGIN-}" ]; then
|
||||
builtin unset ELY_BASH_LOGIN
|
||||
[ -r /etc/profile ] && builtin source /etc/profile
|
||||
@@ -12,8 +12,29 @@ if [ -n "${ELY_BASH_LOGIN-}" ]; then
|
||||
else
|
||||
[ -r ~/.bashrc ] && builtin source ~/.bashrc
|
||||
fi
|
||||
_ely_ran=
|
||||
_ely_armed=
|
||||
_ely_ps0=
|
||||
if (( BASH_VERSINFO[0] * 100 + BASH_VERSINFO[1] >= 404 )); then
|
||||
# PS0 runs in the shell, so its subscript can note that a command ran.
|
||||
_ely_ps0='${_ely_note[_ely_ran=1]-}\e]133;C\a'
|
||||
elif [ -z "$(builtin trap -p DEBUG)" ]; then
|
||||
_ely_debug() {
|
||||
[ -n "$_ely_armed" ] || builtin return 0
|
||||
case $BASH_COMMAND in _ely_*) builtin return 0 ;; esac
|
||||
_ely_armed=
|
||||
_ely_ran=1
|
||||
builtin printf '\e]133;C\a'
|
||||
}
|
||||
builtin trap '_ely_debug' DEBUG
|
||||
fi
|
||||
_ely_prompt() {
|
||||
builtin local ret=$? LC_ALL=C char url= i title
|
||||
_ely_armed=
|
||||
if [ -n "$_ely_ran" ]; then
|
||||
builtin printf '\e]133;D;%s\a' "$ret"
|
||||
_ely_ran=
|
||||
fi
|
||||
for (( i = 0; i < ${#PWD}; i++ )); do
|
||||
char=${PWD:i:1}
|
||||
case $char in
|
||||
@@ -25,4 +46,12 @@ _ely_prompt() {
|
||||
builtin printf '\e]7;file://%s\a\e]2;%s\a' "$url" "${title//[[:cntrl:]]/}"
|
||||
builtin return $ret
|
||||
}
|
||||
PROMPT_COMMAND="_ely_prompt${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
|
||||
# Last, after anything that sets PS1 or PS0.
|
||||
_ely_mark() {
|
||||
[[ $PS1 == *'\e]133;A'* ]] || PS1='\[\e]133;A\a\]'"$PS1"'\[\e]133;B\a\]'
|
||||
if [ -n "$_ely_ps0" ] && builtin shopt -q promptvars && [[ ${PS0-} != *"$_ely_ps0"* ]]; then
|
||||
PS0=$_ely_ps0${PS0-}
|
||||
fi
|
||||
_ely_armed=1
|
||||
}
|
||||
PROMPT_COMMAND="_ely_prompt${PROMPT_COMMAND:+;$PROMPT_COMMAND};_ely_mark"
|
||||
Reference in new issue
Block a user