omf-theme/fish_prompt.fish

93 lines
2.3 KiB
Fish
Raw Normal View History

2016-11-08 02:06:45 +00:00
# forked from Toaster https://github.com/oh-my-fish/theme-toaster
2014-05-01 09:31:46 +00:00
2016-11-08 02:06:45 +00:00
set __slavic_color_orange FD971F
set __slavic_color_blue 6EC9DD
set __slavic_color_green A6E22E
set __slavic_color_yellow E6DB7E
set __slavic_color_pink F92672
set __slavic_color_grey 554F48
set __slavic_color_white F1F1F1
set __slavic_color_purple 9458FF
set __slavic_color_lilac AE81FF
function __slavic_color_echo
2014-05-01 09:31:46 +00:00
set_color $argv[1]
2014-11-03 20:21:56 +00:00
if test (count $argv) -eq 2
echo -n $argv[2]
end
2014-05-01 09:31:46 +00:00
end
2016-11-08 02:06:45 +00:00
function __slavic_current_folder
2014-11-03 20:21:56 +00:00
if test $PWD = '/'
echo -n '/'
else
echo -n $PWD | grep -o -E '[^\/]+$'
end
2014-05-01 09:31:46 +00:00
end
2016-11-08 02:06:45 +00:00
function __slavic_git_status_codes
2014-05-01 09:31:46 +00:00
echo (git status --porcelain ^/dev/null | sed -E 's/(^.{3}).*/\1/' | tr -d ' \n')
end
2016-11-08 02:06:45 +00:00
function __slavic_git_branch_name
2014-05-01 09:31:46 +00:00
echo (git rev-parse --abbrev-ref HEAD ^/dev/null)
end
2016-11-08 02:06:45 +00:00
function __slavic_rainbow
2014-05-01 09:31:46 +00:00
if echo $argv[1] | grep -q -e $argv[3]
2016-11-08 02:06:45 +00:00
__slavic_color_echo $argv[2] "彡ミ"
2014-05-01 09:31:46 +00:00
end
end
2016-11-08 02:06:45 +00:00
function __slavic_git_status_icons
set -l git_status (__slavic_git_status_codes)
2014-05-01 09:31:46 +00:00
2016-11-08 02:06:45 +00:00
__slavic_rainbow $git_status $__slavic_color_pink 'D'
__slavic_rainbow $git_status $__slavic_color_orange 'R'
__slavic_rainbow $git_status $__slavic_color_white 'C'
__slavic_rainbow $git_status $__slavic_color_green 'A'
__slavic_rainbow $git_status $__slavic_color_blue 'U'
__slavic_rainbow $git_status $__slavic_color_lilac 'M'
__slavic_rainbow $git_status $__slavic_color_grey '?'
2014-05-01 09:31:46 +00:00
end
2016-11-08 02:06:45 +00:00
function __slavic_git_status
2014-05-01 09:31:46 +00:00
# In git
2016-11-08 02:06:45 +00:00
if test -n (__slavic_git_branch_name)
2014-05-01 09:31:46 +00:00
2016-11-08 02:06:45 +00:00
__slavic_color_echo $__slavic_color_blue " ☭ "
__slavic_color_echo $__slavic_color_white (__slavic_git_branch_name)
2014-05-01 09:31:46 +00:00
2016-11-08 02:06:45 +00:00
if test -n (__slavic_git_status_codes)
__slavic_color_echo $__slavic_color_pink ' ●'
__slavic_color_echo $__slavic_color_white ' (^._.^)ノ'
__slavic_git_status_icons
2014-05-01 09:31:46 +00:00
else
2016-11-08 02:06:45 +00:00
__slavic_color_echo $__slavic_color_green ' ○'
2014-05-01 09:31:46 +00:00
end
end
end
function fish_prompt
2016-11-08 17:35:06 +00:00
set_color --bold $__slavic_color_lilac
2016-11-07 23:58:10 +00:00
printf '['
switch $fish_bind_mode
case default
set_color --bold red
printf 'n'
case insert
set_color --bold green
printf 'i'
case visual
set_color --bold magenta
printf 'v'
end
2016-11-08 17:35:06 +00:00
set_color $__slavic_color_lilac
2016-11-07 23:58:10 +00:00
printf '] '
2016-11-08 02:06:45 +00:00
__slavic_color_echo $__slavic_color_purple (prompt_pwd)
__slavic_git_status
2016-11-07 23:58:10 +00:00
2014-05-01 09:31:46 +00:00
echo
2016-11-08 02:06:45 +00:00
__slavic_color_echo $__slavic_color_pink "⫸ "
2014-05-01 09:31:46 +00:00
end