Skip to content

Instantly share code, notes, and snippets.

@sbusch
Forked from floxx/gist:fee2f89edbbbbbc08e65
Last active March 9, 2016 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbusch/f41ecb9bcf2f6ec26851 to your computer and use it in GitHub Desktop.
Save sbusch/f41ecb9bcf2f6ec26851 to your computer and use it in GitHub Desktop.
iTerm Tab & Window Titles with zsh and git.original: http://timbabwe.com/2012/05/iterm_tab_and_window_titles_with_zsh
function iterm_tab_and_window_titles_precmd() {
if command git rev-parse --git-dir > /dev/null 2>&1; then
local window_label=$(git rev-parse --show-toplevel)
local tab_label=$(echo $window_label | awk -F\/ '{print "[git] " $NF}')
else
local window_label=${PWD/${HOME}/\~}
local tab_label=$window_label
fi
echo -ne "\e]2;${window_label}\a"
echo -ne "\e]1;${tab_label: -24}\a"
}
add-zsh-hook precmd iterm_tab_and_window_titles_precmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment