Skip to content

Commit 16ff975

Browse files
committed
Show mercurial shelf status in prompt
Should I put this up as a pull request @sjl?
1 parent e30d393 commit 16ff975

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

.bash_profile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function git_ps1
2525

2626
function hg_ps1
2727
{
28-
hg prompt "({root|basename}@{rev}{ {status}}{>{outgoing}}{<{incoming}}) " 2> /dev/null
28+
hg prompt "({root|basename}@{rev}{ {status}{shelf}}{>{outgoing}}{<{incoming}}) " 2> /dev/null
2929
}
3030

3131
PROMPT_COMMAND='bpwd=$(basename `pwd`); echo -ne "\033]0;\007\033k${bpwd}\033\\"'

hg-prompt/prompt.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ def _status(m):
313313

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

316+
def _shelf(m):
317+
try:
318+
shelves_path = repo.join('shelves')
319+
if os.path.exists(shelves_path) and os.listdir(shelves_path):
320+
return _with_groups(m.groups(), '[shelved]')
321+
else:
322+
return ''
323+
except KeyError:
324+
return ''
325+
316326
def _tags(m):
317327
g = m.groups()
318328

@@ -392,6 +402,7 @@ def _update(m):
392402
'rev(\|merge)?': _rev,
393403
'root': _root,
394404
'root\|basename': _basename,
405+
'shelf':_shelf,
395406
'status(?:'
396407
'(\|modified)'
397408
'|(\|unknown)'

0 commit comments

Comments
 (0)