Last active
December 14, 2015 08:09
-
-
Save djromero/5055363 to your computer and use it in GitHub Desktop.
git branch on bash prompt and terminal tab/window title bar
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
get_dir() { | |
printf "%s" $(pwd | sed "s:$HOME:~:") | |
} | |
rename_tab() { | |
echo -ne "\033]0;"$@"\007" | |
} | |
rename_tab_git_branch() { | |
branch=`git symbolic-ref HEAD 2>/dev/null | cut -d/ -f3` | |
if [ "$branch" != "" ]; then | |
rename_tab $branch | |
else | |
rename_tab $(get_dir) | |
fi | |
} | |
GIT_PS1_SHOWUPSTREAM="auto" | |
GIT_PS1_SHOWCOLORHINTS="yes" | |
source ~/.git-prompt.sh | |
source ~/.git-completion.sh | |
export PROMPT_COMMAND='__git_ps1 "\u@\h:\W" "\\\$ ";rename_tab_git_branch;' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment