function parse_git_branch_and_add_brackets { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/' } function get_p4set { echo `p4 set $1 | sed -e "s/$1=//" -e 's/ (.*)$//' 2>&1`; return 0; } function vcsprompt { local NOCOLOR=$(tput op) local YELLOW=$(tput setaf 3) local GRAY=$(tput setaf 7) local CYAN=$(tput setaf 6) local GREEN=$(tput setaf 2) nP4CLIENT=`get_p4set P4CLIENT` nP4PORT=`get_p4set P4PORT` branch=`parse_git_branch_and_add_brackets` if [ ${#nP4CLIENT} -eq 0 ] then nP4CLIENT="__client_unset__" fi if [ ${#nP4PORT} -eq 0 ] then # "p4" actually defaults to using "perforce:1666", so the # P4PORT is never really "unset". nP4PORT="__server_unset__" fi if [ -n "$branch" ] then PS1="\h:\W \u$GREEN\$branch $NOCOLOR\$ " elif [ "$nP4CLIENT" = "__client_unset__" ] then PS1="\h:\W \u \$ " else PS1="\h:\W \u\[$GRAY\][\[$CYAN\]\${nP4CLIENT}\[$GRAY\]@\[$YELLOW\]\${nP4PORT}\[$GRAY\]]\[$NOCOLOR\] \$ " fi } function pcd { exist=`p4 -F %depotFile% files "$1"` path=`p4 -ztag -F %path% where "$1"` if [ -z "$exist" ] then dir=$path else dir=`dirname "$path"` fi cd "$dir" } PROMPT_COMMAND=vcsprompt
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 8503 | Matt Attaway | Fix missing square brace in my bash prompt | ||
#2 | 8381 | Matt Attaway |
Properly protect color codes. Replace hardcoded colors with tput calls |
||
#1 | 8380 | Matt Attaway | Move my bashrc into a more sensible location | ||
//guest/matt_attaway/scripts/.bashrc | |||||
#1 | 8353 | Matt Attaway | Add my new bashrc file to the Public Depot |