Created
February 22, 2017 04:33
-
-
Save notogawa/a3697d119bec32033a6f18a30e2beb13 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function init-prompt-git-branch() | |
{ | |
git symbolic-ref HEAD 2>/dev/null >/dev/null && | |
echo "($(git symbolic-ref HEAD 2>/dev/null | sed 's/^refs\/heads\///'))" | |
} | |
if which git 2>/dev/null >/dev/null | |
then | |
export PS1_GIT_BRANCH='\[\e[$[COLUMNS]D\]\[\e[1;31m\]\[\e[$[COLUMNS-$(length $(init-prompt-git-branch))]C\]$(init-prompt-git-branch)\[\e[$[COLUMNS]D\]\[\e[0m\]' | |
else | |
export PS1_GIT_BRANCH= | |
fi | |
export PS1="\[\e[32;1m\]\u@\H \[\e[33;1m\]\w $PS1_GIT_BRANCH\n\[\e[36;1m\]\t \[\e[0m\]\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment