Created
August 31, 2015 07:03
-
-
Save kaityo256/f4155007cc11cb3254c7 to your computer and use it in GitHub Desktop.
Show status of current repository of git/svn
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
| autoload -U colors; colors | |
| function rprompt-git { | |
| local name st color | |
| name=`git symbolic-ref HEAD 2> /dev/null | sed -e "s/refs\/heads\///g" ` | |
| if [[ -z $name ]]; then | |
| return | |
| fi | |
| st=`git status 2> /dev/null` | |
| if [[ -n `echo "$st" | grep "^nothing to"` ]]; then | |
| color=${fg[green]} | |
| elif [[ -n `echo "$st" | grep "^nothing added"` ]]; then | |
| color=${fg[yellow]} | |
| elif [[ -n `echo "$st" | grep "^# Untracked"` ]]; then | |
| color=${fg_bold[red]} | |
| else | |
| color=${fg[red]} | |
| fi | |
| echo "(%{$color%}$name%{$reset_color%}) " | |
| } | |
| function rprompt-svn { | |
| local name st color stt | |
| st=`LANG=C svn status --depth immediates 2>&1` | |
| if [[ $st =~ "is not" ]]; then | |
| return | |
| fi | |
| if [[ -n `echo $st | grep "^C"` ]];then | |
| color=${fg_bold[red]} | |
| stt="C" | |
| elif [[ -n `echo $st | grep "^M"` ]];then | |
| color=${fg_bold[red]} | |
| stt="M" | |
| elif [[ -n `echo $st | grep "^A"` ]];then | |
| color=${fg_bold[red]} | |
| stt="A" | |
| elif [[ -n `echo $st | grep "^D"` ]];then | |
| color=${fg_bold[red]} | |
| stt="D" | |
| elif [[ -n `echo $st | grep "^\?"` ]];then | |
| color=${fg[yellow]} | |
| stt="?" | |
| else | |
| color=${fg[green]} | |
| stt="N" | |
| fi | |
| echo "(%{$color%}$stt%{$reset_color%})" | |
| } | |
| function rprompt-st { | |
| local st | |
| if [[ ! `git status 2>&1` =~ "Not a git" ]]; then | |
| rprompt-git | |
| elif [[ ! `LANG=C svn st --depth immediates 2>&1` =~ "is not" ]]; then | |
| rprompt-svn | |
| fi | |
| } | |
| RPROMPT='`rprompt-st`%{$fg_bold[cyan]%}[%~]%{$reset_color%}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment