1
0
dotfiles/.config/zsh/lib/title.zsh
Konstantin Demin 0bb93c3b11
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
zsh: minor fixes
2024-02-29 00:15:08 +03:00

59 lines
1.1 KiB
Bash

#!/bin/zsh
ZSHU[title_tab]='%15<..<%~%<<'
ZSHU[title_window]='%n@%m:%~'
z-title-tab() {
emulate -L zsh
case "${TERM}" in
cygwin | xterm* | putty* | rxvt* | konsole* | ansi | mlterm* | alacritty | st* )
print -Pn "\e]1;${1:q}\a"
;;
screen* | tmux* )
## hardstatus
print -Pn "\ek${1:q}\e\\"
;;
* )
z-ti-test fsl tsl || return
echoti tsl
print -Pn "$1"
echoti fsl
;;
esac
}
z-title-window() {
emulate -L zsh
case "${TERM}" in
cygwin | xterm* | putty* | rxvt* | konsole* | ansi | mlterm* | alacritty | st* )
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
echo "tab/window title handling is disabled due to missing hook support" >&2
fi