From e978a3017ca4e85c97cfe619dafdf93bdebe42e5 Mon Sep 17 00:00:00 2001 From: steveokard Date: Tue, 10 Oct 2017 15:37:11 -0400 Subject: [PATCH] set terminal heading regardless of where we are --- .zsh/window.zsh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .zsh/window.zsh diff --git a/.zsh/window.zsh b/.zsh/window.zsh new file mode 100644 index 0000000..a215aef --- /dev/null +++ b/.zsh/window.zsh @@ -0,0 +1,20 @@ + +# From http://dotfiles.org/~_why/.zshrc +# Sets the window title nicely no matter where you are +function title() { + # escape '%' chars in $1, make nonprintables visible + a=${(V)1//\%/\%\%} + + # Truncate command, and join lines. + a=$(print -Pn "%40>...>$a" | tr -d "\n") + + case $TERM in + screen) + print -Pn "\ek$a:$3\e\\" # screen title (in ^A") + ;; + xterm*|rxvt) + print -Pn "\e]2;$2\a" # plain xterm title ($3 for pwd) + ;; + esac +} +