Created
February 14, 2013 17:25
-
-
Save erelson/4954454 to your computer and use it in GitHub Desktop.
Colors for bash prompt. To use this add `source ~/.bash_prompt` to .bashrc. Adapted from Sexy Bash Prompt.
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
# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt" | |
# Screenshot: http://i.imgur.com/uAQSa.png | |
# A big thanks to \amethyst on Freenode | |
# Modified by erelson for colors/compactness, 2/2013. | |
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/ | |
null 2>&1; then TERM=gnome-256color; fi | |
#if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then | |
# MAGENTA=$(tput setaf 5) | |
# ORANGE=$(tput setaf 172) | |
# GREEN=$(tput setaf 190) | |
# PURPLE=$(tput setaf 141) | |
# WHITE=$(tput setaf 256) | |
#else | |
MAGENTA=$(tput setaf 5) | |
ORANGE=$(tput setaf 4) | |
GREEN=$(tput setaf 2) | |
PURPLE=$(tput setaf 1) | |
WHITE=$(tput setaf 7) | |
#fi | |
BOLD=$(tput bold) | |
RESET=$(tput sgr0) | |
parse_git_dirty () { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working direct | |
ory clean)" ]] && echo "¤" | |
} | |
parse_git_branch () { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(pars | |
e_git_dirty)$WHITE}/" | |
} | |
PS1="\[${BOLD}${MAGENTA}\]\u\[$WHITE\]@\[$ORANGE\]\h \[$GREEN\]\w\[$WHITE\]\$([[ | |
-n \$(__git_ps1) ]] && echo \" {\")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\ | |
$ \[$RESET\]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment