Last active
December 18, 2015 12:41
-
-
Save drazenzen/88d24ee9fab819cd6ee8 to your computer and use it in GitHub Desktop.
hg PS1 bash shell helper
This file contains 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 characters
#!/bin/bash | |
# | |
# Ref: http://unix.stackexchange.com/questions/66581 | |
# For getting both exit status and output from command | |
# | |
# __hg_ps1 function shows hg branch and minified hg status when working directory is in a mercurial repo. | |
# | |
__hg_ps1() { | |
local INFO | |
INFO=$(hg branch 2> /dev/null) | |
if [ $? -eq 0 ]; then | |
echo -e "[$INFO $(hg status | cut -b 1 | uniq | sort | tr -d '\n')]" | |
fi | |
} | |
# PS1 example | |
export PS1='$(__hg_ps1)'$PS1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment