-
-
Save jlee42/3062087 to your computer and use it in GitHub Desktop.
My Shell Command Line Format - colored, with Git support and shortened
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
# return the current git branch name | |
parse_git_branch() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ →\ \1/' | |
} | |
# return the string of state of the branch | |
parse_git_dirty() { | |
D="$(git status 2> /dev/null | tail -n1 | awk '{ print $1 }' )" | |
if [ "$D" = "nothing" ] ; then | |
echo -e "(clean) " | |
elif [ "$D" = "no" ]; then | |
echo -e "(modified) " | |
elif [ "$D" = "#" ]; then | |
echo -e "(staged) " | |
else | |
echo "" | |
fi | |
} | |
# Change the command line format and color | |
# \u User name | |
# \h Host name | |
# \w Directory | |
# $(parse_git_branch) Current git branch name | |
export PS1=':\[\e[1;33m\]\W\[\e[0;33m\]$(parse_git_branch)\[\e[0,36m\]$(parse_git_dirty)\[\e[1;33m\]$ \[\e[0m\]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment