diff options
Diffstat (limited to 'share/tools/web_config/sample_prompts/robbyrussell.fish')
-rw-r--r-- | share/tools/web_config/sample_prompts/robbyrussell.fish | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/share/tools/web_config/sample_prompts/robbyrussell.fish b/share/tools/web_config/sample_prompts/robbyrussell.fish index f6641c1a..1c7fa748 100644 --- a/share/tools/web_config/sample_prompts/robbyrussell.fish +++ b/share/tools/web_config/sample_prompts/robbyrussell.fish @@ -1,5 +1,5 @@ # name: Robbyrussell -# author: Bruno Ferreira Pinto +# author: Bruno Ferreira Pinto, Pawel Zubrycki function fish_prompt @@ -8,10 +8,42 @@ function fish_prompt function _git_branch_name echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') end - + function _is_git_dirty echo (git status -s --ignore-submodules=dirty ^/dev/null) end + + function _is_git_repo + git status -s >/dev/null ^/dev/null + end + + function _hg_branch_name + echo (hg branch ^/dev/null) + end + + function _is_hg_dirty + echo (hg status -mard ^/dev/null) + end + + function _is_hg_repo + hg summary >/dev/null ^/dev/null + end + + function _repo_branch_name + eval "_$argv[1]_branch_name" + end + + function _is_repo_dirty + eval "_is_$argv[1]_dirty" + end + + function _repo_type + if _is_hg_repo + echo 'hg' + else if _is_git_repo + echo 'git' + end + end end set -l cyan (set_color -o cyan) @@ -21,17 +53,22 @@ function fish_prompt set -l normal (set_color normal) set -l arrow "$red➜ " + if [ $USER = 'root' ] + set arrow "$red# " + end + set -l cwd $cyan(basename (prompt_pwd)) - if [ (_git_branch_name) ] - set -l git_branch $red(_git_branch_name) - set git_info "$blue git:($git_branch$blue)" + set -l repo_type (_repo_type) + if [ $repo_type ] + set -l repo_branch $red(_repo_branch_name $repo_type) + set repo_info "$blue $repo_type:($repo_branch$blue)" - if [ (_is_git_dirty) ] + if [ (_is_repo_dirty $repo_type) ] set -l dirty "$yellow ✗" - set git_info "$git_info$dirty" + set repo_info "$repo_info$dirty" end end - echo -n -s $arrow ' '$cwd $git_info $normal ' ' + echo -n -s $arrow ' '$cwd $repo_info $normal ' ' end |