1
0
dotfiles/.config/zsh/lib/title.zsh

59 lines
1.1 KiB
Bash
Raw Normal View History

2021-06-05 13:53:16 +03:00
#!/bin/zsh
ZSHU[title_tab]='%15<..<%~%<<'
ZSHU[title_window]='%n@%m:%~'
z-title-tab() {
emulate -L zsh
case "${TERM}" in
2024-01-27 00:10:58 +03:00
cygwin | xterm* | putty* | rxvt* | konsole* | ansi | mlterm* | alacritty | st* )
2021-06-05 13:53:16 +03:00
print -Pn "\e]1;${1:q}\a"
;;
2024-01-27 00:10:58 +03:00
screen* | tmux* )
2021-06-05 13:53:16 +03:00
## hardstatus
print -Pn "\ek${1:q}\e\\"
;;
2024-01-27 00:10:58 +03:00
* )
2021-07-29 08:53:10 +03:00
z-ti-test fsl tsl || return
2021-06-05 13:53:16 +03:00
echoti tsl
print -Pn "$1"
echoti fsl
;;
esac
}
z-title-window() {
emulate -L zsh
case "${TERM}" in
2024-01-27 00:10:58 +03:00
cygwin | xterm* | putty* | rxvt* | konsole* | ansi | mlterm* | alacritty | st* )
2021-06-05 13:53:16 +03:00
print -Pn "\e]2;${1:q}\a"
;;
esac
}
z-title() {
emulate -L zsh
## if $2 is unset use $1 as default
## if it is set and empty, leave it as is
: ${2=$1}
z-title-tab "$1"
z-title-window "$2"
}
if autoload -Uz add-zsh-hook ; then
__z_title_precmd() {
z-title "${ZSHU[title_tab]}" "${ZSHU[title_window]}"
}
add-zsh-hook precmd __z_title_precmd
else
2024-02-29 00:15:08 +03:00
echo "tab/window title handling is disabled due to missing hook support" >&2
2021-06-05 13:53:16 +03:00
fi