Skip to content

Instantly share code, notes, and snippets.

@jimjam88
Created August 22, 2014 19:39
Show Gist options
  • Select an option

  • Save jimjam88/84bff0209c214b519388 to your computer and use it in GitHub Desktop.

Select an option

Save jimjam88/84bff0209c214b519388 to your computer and use it in GitHub Desktop.
Mercurial branch in command prompt
function hg_in_repo() {
hg branch 2> /dev/null | awk '{print "on "}'
}
function hg_dirty() {
hg status --no-color 2> /dev/null \
| awk '$1 == "?" { print "?" } $1 != "?" { print "!" }' \
| sort | uniq | head -c1
}
function hg_branch() {
hg branch 2> /dev/null | awk '{print $1}'
}
function hg_prompt() {
hg branch 2> /dev/null > /dev/null && echo "($(hg_branch)$(hg_dirty))"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment