Last active
September 18, 2023 16:27
-
-
Save keyganker/6b36ab4bb72a7d7f31dec70055ad851a to your computer and use it in GitHub Desktop.
git branch name prompt in shell #shell
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
function git_branch { | |
branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`" | |
if [ "${branch}" != "" ];then | |
if [ "${branch}" = "(no branch)" ];then | |
branch="(`git rev-parse --short HEAD`...)" | |
fi | |
echo " ($branch)" | |
fi | |
} | |
export PS1='\u@ \[\033[32;40m\]\w\[\033[01;32m\]$(git_branch)\[\033[00m\] \$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment