diff options
author | Lee Nussbaum <wln@scrunch.org> | 2009-05-20 22:38:07 +0800 |
---|---|---|
committer | Leonid Volnitsky <leonid@volnitsky.com> | 2009-05-22 14:49:55 +0800 |
commit | 77142a4698816663a8055b41d4f8d6832f7acaeb (patch) | |
tree | cefdbb1398bd7f604d8a27ebea91441b24f61486 /git-prompt.sh | |
parent | fixed: lable display for gnu-screen (diff) | |
download | git-prompt-77142a4698816663a8055b41d4f8d6832f7acaeb.tar.gz git-prompt-77142a4698816663a8055b41d4f8d6832f7acaeb.tar.bz2 git-prompt-77142a4698816663a8055b41d4f8d6832f7acaeb.zip |
Simple mercurial (hg) support in prompt.
Signed-off-by: Leonid Volnitsky <leonid@volnitsky.com>
Diffstat (limited to 'git-prompt.sh')
-rwxr-xr-x[-rw-r--r--] | git-prompt.sh | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/git-prompt.sh b/git-prompt.sh index 311b9c2..f653865 100644..100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -18,6 +18,7 @@ git_module=${git_module:-on} svn_module=${svn_module:-off} + hg_module=${hg_module:-on} vim_module=${vim_module:-on} error_bell=${error_bell:-off} @@ -274,10 +275,34 @@ parse_svn_dir() { vcs_info=svn:r$rev } - -#parse_hg_dir() { -# http://stevelosh.com/blog/entry/2009/3/17/mercurial-bash-prompts/ -#} +parse_hg_dir() { + if [[ $hg_module = "off" || $HOME == $PWD ]]; then + return 1 + fi + + if [[ -z `hg branch 2> /dev/null` ]]; then + return 1 + fi + + vcs=hg + + ### get status + unset status modified added clean init added mixed untracked op detached + + eval `hg status 2>/dev/null | + sed -n ' + s/^M \([^.].*\)/modified=modified; modified_files[${#modified_files[@]}+1]=\"\1\";/p + s/^A \([^.].*\)/added=added; added_files[${#added_files[@]}+1]=\"\1\";/p + s/^R \([^.].*\)/added=added;/p + s/^! \([^.].*\)/modified=modified;/p + s/^? \([^.].*\)/untracked=untracked; untracked_files[${#untracked_files[@]}+1]=\\"\1\\";/p + '` + + branch=`hg branch 2> /dev/null` + + [[ -z $modified ]] && [[ -z $untracked ]] && [[ -z $added ]] && clean=clean + vcs_info=${branch/default/D} +} parse_git_dir() { @@ -408,7 +433,7 @@ parse_vcs_dir() { unset status modified untracked added init detached unset file_list modified_files untracked_files added_files - parse_git_dir || parse_svn_dir || return + parse_git_dir || parse_svn_dir || parse_hg_dir || return ### status: choose primary (for branch color) |