fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
17fdd2f15
master
1function fish_fossil_prompt --description'Write out the fossil prompt' 2# Bail if fossil is not available 3if not command -sq fossil 4return 1 5end 6 7# Read branch and bookmark (bail if not checkout) 8set -l branch( fossil branch current2> /dev/null) 9or return 127 10 11set -q fish_color_fossil_clean 12or set -g fish_color_fossil_clean green 13set -q fish_color_fossil_modified 14or set -g fish_color_fossil_modified yellow 15set -q fish_color_fossil_dirty 16or set -g fish_color_fossil_dirty red 17 18set -q fish_color_fossil_added 19or set -g fish_color_fossil_added green 20set -q fish_color_fossil_renamed 21or set -g fish_color_fossil_renamed magenta 22set -q fish_color_fossil_missing 23or set -g fish_color_fossil_missing red 24set -q fish_color_fossil_deleted 25or set -g fish_color_fossil_deleted red 26set -q fish_color_fossil_untracked 27or set -g fish_color_fossil_untracked yellow 28set -q fish_color_fossil_conflict 29or set -g fish_color_fossil_conflict red 30 31set -q fish_prompt_fossil_status_added 32or set -g fish_prompt_fossil_status_added'✚' 33set -q fish_prompt_fossil_status_modified 34or set -g fish_prompt_fossil_status_modified'*' 35set -q fish_prompt_fossil_status_renamed 36or set -g fish_prompt_fossil_status_renamed'⇒' 37set -q fish_prompt_fossil_status_deleted 38or set -g fish_prompt_fossil_status_deleted - 39set -q fish_prompt_fossil_status_missing 40or set -g fish_prompt_fossil_status_missing'✖' 41set -q fish_prompt_fossil_status_untracked 42or set -g fish_prompt_fossil_status_untracked'?' 43set -q fish_prompt_fossil_status_conflict 44or set -g fish_prompt_fossil_status_conflict'×' 45 46set -q fish_prompt_fossil_status_order 47or set -g fish_prompt_fossil_status_order added modified renamed deleted missing untracked conflict 48 49echo -n' (' 50set_color magenta 51echo -n" $branch " | string replace -ra'[[:cntrl:]]' '' 52set_color --reset 53echo -n'|' 54#set -l repo_status (fossil changes --differ 2>/dev/null | string match -rv '\w:|^\s' | string split " " -f1 | sort -u) 55set -l repo_status( fossil changes --differ2> /dev/null| string match -rv'\w:|^\s' | string split" " -f1| path sort -u) 56 57# Show nice color for a clean repo 58if test -z " $repo_status " 59set_color $fish_color_fossil_clean 60echo -n'✔' 61 62# Handle modified or dirty (unknown state) 63else 64set -l fossil_statuses 65 66# Take actions for the statuses of the files in the repo 67for linein $repo_status 68 69# Add a character for each file status if we have one 70switch $line 71case ADDED 72set -a fossil_statuses added 73case EDITED 74set -a fossil_statuses modified 75case EXTRA 76set -a fossil_statuses untracked 77case DELETED 78set -a fossil_statuses deleted 79case MISSING 80set -a fossil_statuses missing 81case RENAMED 82set -a fossil_statuses renamed 83case CONFLICT 84set -a fossil_statuses conflict 85end 86end 87 88if string match -qr'^(ADDED|EDITED|DELETED)' $repo_status 89set_color $fish_color_fossil_modified 90else 91set_color --bold$fish_color_fossil_dirty 92end 93 94echo -n'⚡' 95set_color --reset 96 97# Sort status symbols 98for iin $fish_prompt_fossil_status_order 99if contains --$i $fossil_statuses 100set -l color_name fish_color_fossil_$i 101set -l status_name fish_prompt_fossil_status_$i 102 103set_color $$color_name 104echo -n$$status_name 105end 106end 107end 108 109set_color --reset 110echo -n')' 111end