fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
17fdd2f15
master
1# Adapted from __terlar_git_prompt 2 3set -g fish_color_hg_clean green 4set -g fish_color_hg_modified yellow 5set -g fish_color_hg_dirty red 6 7set -g fish_color_hg_added green 8set -g fish_color_hg_renamed magenta 9set -g fish_color_hg_copied magenta 10set -g fish_color_hg_deleted red 11set -g fish_color_hg_untracked yellow 12set -g fish_color_hg_unmerged red 13 14set -g fish_prompt_hg_status_added'✚' 15set -g fish_prompt_hg_status_modified'*' 16set -g fish_prompt_hg_status_copied'⇒' 17set -g fish_prompt_hg_status_deleted'✖' 18set -g fish_prompt_hg_status_untracked'?' 19set -g fish_prompt_hg_status_unmerged ! 20 21set -g fish_prompt_hg_status_order added modified copied deleted untracked unmerged 22 23function fish_hg_prompt --description'Write out the hg prompt' 24# If hg isn't installed, there's nothing we can do 25# Return 1 so the calling prompt can deal with it 26if not command -sq hg 27return 1 28end 29 30set -l root( fish_print_hg_root ) 31or return 1 32 33# Read branch and bookmark 34set -l branch( cat $root /branch2> /dev/null;or echo default) 35if set -l bookmark( cat $root /bookmarks.current2> /dev/null) 36set branch" $branch | $bookmark " 37end 38 39# Strip control characters for display. 40set branch( string replace -ra'[[:cntrl:]]' '' --$branch ) 41 42if not set -q fish_prompt_hg_show_informative_status 43set_color --reset 44echo -n" ( $branch ) " 45return 46end 47 48echo -n'|' 49 50# Disabling color and pager is always a good idea. 51set -l repo_status( hg status| string sub -l2 | sort -u) 52 53# Show nice color for a clean repo 54if test -z " $repo_status " 55set_color $fish_color_hg_clean 56echo -n" ( $branch ) "'✓' 57set_color --reset 58 59# Handle modified or dirty (unknown state) 60else 61set -l hg_statuses 62 63# Take actions for the statuses of the files in the repo 64for linein $repo_status 65 66# Add a character for each file status if we have one 67# HACK: To allow this to work both with and without '?' globs 68set -l dq'?' 69switch $line 70case 'A ' 71set -a hg_statuses added 72case 'M ' ' M' 73set -a hg_statuses modified 74case 'C ' 75set -a hg_statuses copied 76case 'D ' ' D' 77set -a hg_statuses deleted 78case " $dq " 79set -a hg_statuses untracked 80case 'U*' '*U' DD AA 81set -a hg_statuses unmerged 82end 83end 84 85if string match -qr'^[AMCD]' $repo_status 86set_color $fish_color_hg_modified 87else 88set_color $fish_color_hg_dirty 89end 90 91echo -n" ( $branch ) "'⚡' 92 93# Sort status symbols 94for iin $fish_prompt_hg_status_order 95if contains --$i $hg_statuses 96set -l color_name fish_color_hg_$i 97set -l status_name fish_prompt_hg_status_$i 98 99set_color $$color_name 100echo -n$$status_name 101end 102end 103 104set_color --reset 105end 106 107end