dotfiles/zsh/files/termsupport.zsh

44 lines
815 B
Bash

function title {
emulate -L zsh
setopt prompt_subst
[[ "$EMACS" == *term* ]] && return
: ${2=$1}
case "$TERM" in
cygwin|xterm*|putty*|rxvt*|ansi)
print -Pn "\e]2;$2:q\a"
print -Pn "\e]1;$1:q\a"
;;
screen*|tmux*)
print -Pn "\ek$1:q\e\\"
;;
*)
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
echoti tsl
print -Pn "$1"
echoti fsl
fi
;;
esac
}
function omz_termsupport_precmd {
emulate -L zsh
title '%15<..<%~%<<' '%n@%m: %~'
}
function omz_termsupport_preexec {
emulate -L zsh
setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
local LINE="${2:gs/%/%%}"
title '$CMD' '%100>...>$LINE%<<'
}
precmd_functions+=(omz_termsupport_precmd)
preexec_functions+=(omz_termsupport_preexec)