mirror of https://github.com/bjeanes/dotfiles.git
Upgraded vcprompt to fix the empty-git-repo issue causing stderr output in the prompt
parent
29225e7f9b
commit
abdd22288f
|
@ -521,34 +521,30 @@ def git(path, string, unknown):
|
|||
# hash/revision
|
||||
if re.search('%(r|h)', string) and branch != unknown:
|
||||
hash_file = os.path.join(file, 'refs/heads/%s' % branch)
|
||||
with open(hash_file, 'r') as f:
|
||||
for line in f:
|
||||
hash = line.strip()[0:7]
|
||||
break
|
||||
if os.path.exists(hash_file):
|
||||
with open(hash_file, 'r') as f:
|
||||
for line in f:
|
||||
hash = line.strip()[0:7]
|
||||
break
|
||||
|
||||
# status
|
||||
if '%i' in string:
|
||||
command = 'git status'
|
||||
command = 'git status --short -z'
|
||||
process = Popen(command.split(), stdout=PIPE, stderr=PIPE)
|
||||
output = process.communicate()[0]
|
||||
returncode = process.returncode
|
||||
|
||||
if not returncode:
|
||||
headers = {'modified': 'M',
|
||||
'removed': 'D',
|
||||
'renamed': 'R',
|
||||
'Untracked': '?'}
|
||||
status = ''
|
||||
status = 'clean'
|
||||
status_codes = []
|
||||
for line in output.split('\n'):
|
||||
# strip the hashes from the lines
|
||||
line = line[1:].strip()
|
||||
# ignore informational and blank lines
|
||||
if line and not line.startswith('('):
|
||||
for key in headers.keys():
|
||||
if line.startswith(key):
|
||||
status += headers[key]
|
||||
break
|
||||
status = sorted_alpha(status)
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
status_codes.append(line.split()[0])
|
||||
|
||||
if status_codes:
|
||||
status = sorted_alpha(status_codes)
|
||||
|
||||
# formatting
|
||||
string = string.replace('%b', branch)
|
||||
|
|
|
@ -16,4 +16,4 @@ ZSH_THEME_VCS_PROMPT_SUFFIX="›%{$reset_color%}"
|
|||
ZSH_THEME_VCS_PROMPT_FORMAT="${ZSH_THEME_VCS_PROMPT_PREFIX}%b:%h${ZSH_THEME_VCS_PROMPT_SUFFIX}"
|
||||
|
||||
PS1='%{$fg[blue]%}$(prompt_pwd)%{$reset_color%} %{$fg[$(prompt_color)]%}♪%{$reset_color%} '
|
||||
RPS1='$(${VCPROMPT} -f ${ZSH_THEME_VCS_PROMPT_FORMAT} 2>/dev/null)'
|
||||
RPS1='$(${VCPROMPT} -f ${ZSH_THEME_VCS_PROMPT_FORMAT})'
|
||||
|
|
Loading…
Reference in New Issue