Skip to content

Instantly share code, notes, and snippets.

@scarolan
Last active November 20, 2015 19:27
Show Gist options
  • Save scarolan/f93a8f9b362c4d3a4436 to your computer and use it in GitHub Desktop.
Save scarolan/f93a8f9b362c4d3a4436 to your computer and use it in GitHub Desktop.
Set the tab name in iTerm to contain the current directory and git branch
function set_iterm_title {
echo -ne "\e]1;$1\a"
}
function git_branch {
BRANCH_REFS=$(git symbolic-ref HEAD 2>/dev/null) || return
GIT_BRANCH="${BRANCH_REFS#refs/heads/}"
[ -n "$GIT_BRANCH" ] && echo "$GIT_BRANCH "
}
function precmd {
set_iterm_title "${PWD//*\//} $(git_branch)"
#PROMPT="%c %{$fg[cyan]%}$(git_branch)%{$reset_color%}%# "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment