Created
July 31, 2018 12:29
-
-
Save lissahyacinth/acccd266662674c4d02e86f85e789b10 to your computer and use it in GitHub Desktop.
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
# Changing Prompt for Bash | |
inside_git_repo="\$(git rev-parse --is-inside-work-tree 2>/dev/null)" | |
parse_git_branch() { | |
if [ "$inside_git_repo" ]; then | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
else echo "" | |
fi | |
} | |
parse_git_commit() { | |
if [ "$inside_git_repo" ]; then | |
git log --pretty=format:'%h' -n 1 2> /dev/null | tr -d '\n' | |
else echo "" | |
fi | |
} | |
export PS1="\W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] \$(parse_git_commit) \$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment