Created
September 21, 2014 07:03
-
-
Save kellishaver/bb8b3a2473b54860f568 to your computer and use it in GitHub Desktop.
Customize your command prompt with useful Git info
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
export TERM=xterm-256color | |
MAGENTA=$(tput setaf 9) | |
ORANGE=$(tput setaf 172) | |
YELLOW=$(tput setaf 190) | |
PURPLE=$(tput setaf 141) | |
BOLD=$(tput bold) | |
RESET=$(tput sgr0) | |
export MAGENTA | |
export ORANGE | |
export YELLOW | |
export PURPLE | |
export BOLD | |
export RESET | |
function parse_git_dirty() { | |
[[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && echo "$MAGENTA*$RESET" | |
} | |
function parse_git_branch() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" | |
} | |
export PS1="\[${BOLD}${ORANGE}\]\u \[$YELLOW\]\w\[$RESET\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on branch: \")\[$PURPLE\]\$(parse_git_branch)\n> \[$RESET\]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello