Created
September 14, 2017 20:30
-
-
Save caugner/59a3863314702de01ec07848ad0538ed to your computer and use it in GitHub Desktop.
prompt_hg()
This file contains hidden or 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
| prompt_hg() { | |
| (( $+commands[hg] )) || return | |
| local rev status | |
| if $(hg root 2> /dev/null); then | |
| if $(hg prompt >/dev/null 2>&1); then | |
| if [[ $(hg prompt "{status|unknown}") = "?" ]]; then | |
| # if files are not added | |
| prompt_segment red white | |
| st='±' | |
| elif [[ -n $(hg prompt "{status|modified}") ]]; then | |
| # if any modification | |
| prompt_segment yellow black | |
| st='±' | |
| else | |
| # if working copy is clean | |
| prompt_segment green black | |
| fi | |
| echo -n $(hg prompt "☿ {rev}@{branch}") $st | |
| else | |
| hgst=$(hg st -uma | cut -c -1 | sort | uniq | paste -d, -s) | |
| st="" | |
| rev_branch=$(hg id -nb 2>/dev/null) | |
| if `echo "$hgst" | grep -q "[?]"`; then | |
| prompt_segment red black | |
| elif `echo "$hgst" | grep -q "[MA]"`; then | |
| prompt_segment yellow black | |
| else | |
| prompt_segment green black | |
| fi | |
| echo -n "☿ $rev_branch" $st | |
| fi | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment