Created
March 3, 2019 03:09
-
-
Save Trucido/2956fa58b1f5d0bbaef35df3e6442beb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ((! ${+precmd_functions[(r)__vte_osc7|title_precmd]}${+preexec_functions[(r)title_preexec]})) | |
then | |
function title { | |
[[ ( ! -o interactive || $- != *i* ) || $EMACS == *t* ]] && return | |
emulate -L zsh -o promptsubst -o extendedglob | |
: ${2=$1} | |
case ${TERM} in | |
[aEkx]term*|(#i)rxvt*|(#i)vte*|(#i)cygwin*|(#i)[pk][ui]tty*) | |
print -Pn "\e]2;$2:q\a"; print -Pn "\e]1;$1:q\a" ;; | |
screen*) | |
print -Pn "\ek$1:q\e\\" ;; | |
*) | |
zmodload -e zsh/terminfo || zmodload -i zsh/terminfo | |
if [[ -n ${terminfo[fsl]} && -n ${terminfo[tsl]} ]]; then | |
echoti tsl; print -Pn "$1"; echoti fsl | |
fi ;; | |
esac | |
} | |
function title_precmd { | |
emulate -L zsh | |
local TIDLE="%15<..<%~%<<" | |
local WIDLE="%n@%m: %~" | |
title $TIDLE $WIDLE | |
} | |
function title_preexec { | |
emulate -L zsh -o extendedglob | |
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%} | |
local LINE="${2:gs/%/%%}" | |
title '$CMD' '%100>...>$LINE%<<' | |
} | |
add-zsh-hook precmd title_precmd | |
add-zsh-hook preexec title_preexec | |
fi | |
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | |
# vim: ft=zsh sw=2 ts=2 et |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment