Last active
January 1, 2016 16:19
-
-
Save pyatil/8170016 to your computer and use it in GitHub Desktop.
Revisions
-
pyatil revised this gist
Dec 30, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,11 +20,11 @@ def flush(self): def color(): if 'working directory clean' in git_status: return '${grey}[%s]' % branch() # green elif 'Not a git repository' in git_status: return '' else: return '${red}[%s]' % branch() # red def branch(): try: -
pyatil revised this gist
Dec 29, 2013 . 1 changed file with 12 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,15 +5,24 @@ """ import re import sh class my_err_out(): def __init__(self): self.merr = '' def write(self, line): self.merr += line def flush(self): pass cur_err = my_err_out() try: git_status = sh.git("status", _err=cur_err) except: git_status = cur_err.merr def color(): if 'working directory clean' in git_status: return '\033[1;32m[%s]' % branch() # green elif 'Not a git repository' in git_status: return '' else: return '\033[4;31m[%s]' % branch() # red -
pyatil created this gist
Dec 29, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ #/usr/bin/python # coding: utf-8 """ prompt for status git """ import re import sh try: git_status = sh.git("status") except: git_status = '' def color(): if 'working directory clean' in git_status: return '\033[1;32m[%s]' % branch() # green else: return '\033[4;31m[%s]' % branch() # red def branch(): try: cur_brunch = re.findall("# On branch (.*)", str(git_status))[0] except: cur_brunch = '' return cur_brunch if __name__ == '__main__': import sys if sys.argv[1] == 'color': sys.stdout.write(color()) else: print branch() 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ autoload -U colors && colors for color in red green yellow blue magenta cyan black white; do eval $color='%{$fg_no_bold[${color}]%}' #eval ${color}_bold='%{$fg_bold[${color}]%}' done reset="%{$reset_color%}" if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then host="${black}[${blue}%m${black}] " #SSH else unset host # no SSH fi my_git() { python /home/snu/Projects/git/git_prompt.py color } setopt prompt_subst # git precmd() { GIT=$(my_git) if [ "$EUID" -eq 0 ]; then PROMPT="${host}${red}[${magenta}%2c${red}]${reset} " # root else PROMPT="${green}[%T]${black} ${host}${black}[${magenta}%2c${black}] $GIT${reset} " # user fi }