fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
867946468
master
1# name: Arrow 2# author: Bruno Ferreira Pinto, Pawel Zubrycki 3 4function fish_prompt 5set -l __last_command_exit_status$status 6 7if not set -q -g __fish_arrow_functions_defined 8set -g __fish_arrow_functions_defined 9function _git_branch_name 10set -l branch( git symbolic-ref --quiet HEAD2> /dev/null) 11if set -q branch[ 1 ] 12echo ( string replace -r'^refs/heads/' '' $branch ) 13else 14echo ( git rev-parse --short HEAD2> /dev/null) 15end 16end 17 18function _is_git_dirty 19not command git diff-index --cached --quiet HEAD --&> /dev/null 20or not command git diff --no-ext-diff --quiet --exit-code&> /dev/null 21end 22 23function _is_git_repo 24type -q git 25or return 1 26git rev-parse --git-dir> /dev/null2>&1 27end 28 29function _hg_branch_name 30echo ( hg branch2> /dev/null) 31end 32 33function _is_hg_dirty 34set -l stat( hg status -mard2> /dev/null) 35test -n " $stat " 36end 37 38function _is_hg_repo 39fish_print_hg_root > /dev/null 40end 41 42function _repo_branch_name 43 _$argv [ 1 ] _branch_name 44end 45 46function _is_repo_dirty 47 _is_$argv [ 1 ] _dirty 48end 49 50function _repo_type 51if _is_hg_repo 52echo hg 53return 0 54else if _is_git_repo 55echo git 56return 0 57end 58return 1 59end 60end 61 62set -l cyan( set_color -o cyan) 63set -l yellow( set_color -o yellow) 64set -l red( set_color -o red) 65set -l green( set_color -o green) 66set -l blue( set_color -o blue) 67set -l normal( set_color --reset) 68 69set -l arrow_color" $green " 70if test $__last_command_exit_status != 0 71set arrow_color" $red " 72end 73 74set -l arrow" $arrow_color ➜ " 75if fish_is_root_user 76set arrow" $arrow_color # " 77end 78 79set -l cwd$cyan ( prompt_pwd | path basename) 80 81set -l repo_info 82if set -l repo_type( _repo_type ) 83set -l repo_branch$red ( _repo_branch_name $repo_type ) 84set repo_info" $blue $repo_type :( $repo_branch$blue )" 85 86if _is_repo_dirty $repo_type 87set -l dirty" $yellow ✗" 88set repo_info" $repo_info$dirty " 89end 90end 91 92echo -n -s$arrow ' ' $cwd $repo_info $normal ' ' 93end