dotfiles/config/fish/functions/fish_prompt.fish

70 lines
1.6 KiB
Fish
Raw Normal View History

2018-06-09 22:17:36 +00:00
#!/usr/bin/fish
# Fish git prompt
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showstashstate 'yes'
set __fish_git_prompt_showuntrackedfiles 'yes'
set __fish_git_prompt_showupstream 'yes'
set __fish_git_prompt_color_branch yellow
set __fish_git_prompt_color_upstream_ahead green
set __fish_git_prompt_color_upstream_behind red
# Status Chars
2018-06-09 22:42:20 +00:00
set __fish_git_prompt_char_dirtystate '+'
2018-11-25 20:50:36 +00:00
set __fish_git_prompt_char_stagedstate '•'
set __fish_git_prompt_char_untrackedfiles '…'
set __fish_git_prompt_char_stashstate '⚑'
set __fish_git_prompt_char_upstream_ahead '⇡'
set __fish_git_prompt_char_upstream_behind '⇣'
2018-06-09 22:17:36 +00:00
2020-03-04 12:27:36 +00:00
set __prompt_bg 404552
2018-06-09 22:17:36 +00:00
function fish_prompt
2018-11-25 20:50:36 +00:00
echo
2018-06-09 22:17:36 +00:00
2018-11-25 21:06:45 +00:00
if [ (id -u) -eq "0" ]
set_color -o red -b $__prompt_bg
else
set_color -o green -b $__prompt_bg
end
2018-11-25 20:50:36 +00:00
2018-11-25 21:06:45 +00:00
echo -n $PWD | sed -e "s,^$HOME,~,"
set_color normal -b $__prompt_bg
printf '%s\e[K\n' (__fish_git_prompt | sed -r 's/(\x1B\[0?)m/\139m/')
2018-11-25 20:50:36 +00:00
if [ (id -u) -eq "0" ]
2018-11-25 20:50:36 +00:00
set_color red
echo -n "# "
else
if [ "$USER" = "sijmen" ]
2018-11-25 21:06:45 +00:00
set_color green
2018-11-25 20:50:36 +00:00
else
2018-11-25 21:06:45 +00:00
set_color blue
2018-11-25 20:50:36 +00:00
end
echo -n "\$ "
end
2018-06-09 22:17:36 +00:00
2019-10-19 12:11:56 +00:00
# set_color black
# echo -n ""
2018-11-25 20:50:36 +00:00
set_color normal
echo -n " "
2018-06-09 22:17:36 +00:00
2018-11-25 21:06:45 +00:00
z --add "$PWD"
2018-11-25 20:50:36 +00:00
end
function fish_right_prompt
if [ $CMD_DURATION -lt 3000 ]
return
end
2018-06-09 22:42:20 +00:00
2018-11-25 20:50:36 +00:00
echo -n " "
set_color black -b $__prompt_bg
2019-10-19 12:11:56 +00:00
#echo -n ""
2018-11-25 20:50:36 +00:00
set_color blue
printf " %dm %02ds" (expr $CMD_DURATION / 60000) (expr $CMD_DURATION / 1000 \% 60)
set_color normal
2018-06-09 22:17:36 +00:00
end