Skip to content

Commit

Permalink
Show mercurial shelf status in prompt
Browse files Browse the repository at this point in the history
Should I put this up as a pull request @sjl?
  • Loading branch information
jlfwong committed May 9, 2012
1 parent e30d393 commit 16ff975
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function git_ps1

function hg_ps1
{
hg prompt "({root|basename}@{rev}{ {status}}{>{outgoing}}{<{incoming}}) " 2> /dev/null
hg prompt "({root|basename}@{rev}{ {status}{shelf}}{>{outgoing}}{<{incoming}}) " 2> /dev/null
}

PROMPT_COMMAND='bpwd=$(basename `pwd`); echo -ne "\033]0;\007\033k${bpwd}\033\\"'
Expand Down
11 changes: 11 additions & 0 deletions hg-prompt/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,16 @@ def _status(m):

return _with_groups(g, flag) if flag else ''

def _shelf(m):
try:
shelves_path = repo.join('shelves')
if os.path.exists(shelves_path) and os.listdir(shelves_path):
return _with_groups(m.groups(), '[shelved]')
else:
return ''
except KeyError:
return ''

def _tags(m):
g = m.groups()

Expand Down Expand Up @@ -392,6 +402,7 @@ def _update(m):
'rev(\|merge)?': _rev,
'root': _root,
'root\|basename': _basename,
'shelf':_shelf,
'status(?:'
'(\|modified)'
'|(\|unknown)'
Expand Down

0 comments on commit 16ff975

Please sign in to comment.