Created
May 31, 2009 07:17
-
-
Save nesquena/120804 to your computer and use it in GitHub Desktop.
simple git branch ps1 with colored dirty state
This file contains hidden or 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
# COLORS | |
LIGHT_GRAY="\[\033[0;37m\]"; BLUE="\[\033[1;36m\]"; RED="\[\033[0;31m\]"; LIGHT_RED="\[\033[1;31m\]"; | |
GREEN="\[\033[0;32m\]"; WHITE="\[\033[1;37m\]"; LIGHT_GRAY="\[\033[0;37m\]"; YELLOW="\[\033[1;33m\]"; | |
# GIT PROMPT (http://gist.github.com/120804) | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/'; | |
} | |
function parse_git_status { | |
git status 2> /dev/null | sed -e '/(working directory clean)$/!d' | wc -l; | |
} | |
function check_git_changes { | |
# tput setaf 1 = RED, tput setaf 2 = GREEN | |
[ `parse_git_status` -ne 1 ] && tput setaf 1 || tput setaf 2 | |
} | |
export PS1="$YELLOW\w\[\$(check_git_changes)\]\$(parse_git_branch)$LIGHT_GRAY $ " |
IPADDRS=ifconfig |grep inet|grep -v "127.0.0.1"|sed -n '2p'|awk '{print $2}'|awk -F ':' '{print $2}'
export PS1="[\033[0m]IP => [\033[1;33m]$IPADDRS [\033[0m]Time:[\033[1;35m]\t [\033[0m]User:[\033[1;33m]\u [\033[0m]History:[\033[1;33m]! [\033[0m]\n
这样丰富了~
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
直接用 zsh + oh-my-zsh 多好..