Created
November 9, 2017 10:16
-
-
Save terrettaz/473ef73d49a6bec74a1a6d6f6550e802 to your computer and use it in GitHub Desktop.
Gist than display fast Mercurial info
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
# Version 1.1 | |
__get_hg_dir() { | |
local d=`readlink -f "$1"` | |
if [ -d "$d/.hg" ]; then | |
echo "$d/.hg" | |
return 0 | |
elif [ "$d" == "/" ]; then | |
echo "" | |
return 1 | |
else | |
__get_hg_dir "$(dirname "$d")" | |
return $? | |
fi | |
} | |
__parse_hg_dirty() { | |
return 0 # COMMENT THIS LINE FOR DIRTY FLAG | |
[[ $( hg status 2> /dev/null ) != "" ]] && echo "⚡" | |
} | |
__parse_hg_branch() { | |
branch=$( cat "$1/branch" 2> /dev/null | sed -e 's/\(.*\)/\1/' ) | |
[[ $branch != 'default' ]] && echo "$branch" | |
} | |
__diplay_hg_branch() { | |
hg_dir=$(__get_hg_dir .) | |
if [ $? -eq 0 ]; then | |
echo "[$(__parse_hg_branch "$hg_dir")$(__parse_hg_dirty)]" | |
fi | |
} | |
export PS1='\[\033[01;33m\]me \[\033[01;34m\]\W \[\033[01;90m\]$(__diplay_hg_branch)\[\033[01;37m\]\$ \[\033[00m\]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment