homes/common/.config/fish/functions/fish_prompt.fish

165 lines
6.4 KiB
Fish
Raw Normal View History

2023-09-04 16:14:08 +02:00
# name: Nerv
# author: kujiu
# description: based on Astronaut of Radu Potop and on Disco of Fabian Homborg, colors from Nightfox by EdenEast
function fish_prompt --description 'Write out the prompt'
2023-09-06 03:06:11 +02:00
set -f color_venv $nightfox_fg3
2023-09-04 16:14:08 +02:00
set -f color_bind normal
2023-09-06 03:06:11 +02:00
set -f color_text $nightfox_bg0
set -f color_status $nightfox_green
set -f color_bind $nightfox_green
2023-09-04 16:14:08 +02:00
set -f color_cwd $fish_color_cwd
2023-09-06 03:06:11 +02:00
set -f color_vcs_text $nightfox_yellow
set -f color_vcs_bg $nightfox_bg2
2023-09-04 16:14:08 +02:00
set -f char_bind 'E'
2023-09-06 02:22:26 +02:00
set -f last_status $status
set -f normal (set_color normal)
2023-10-02 00:57:35 +02:00
set -f prompt_status "fish✔"
2023-09-04 16:14:08 +02:00
2023-09-06 03:06:11 +02:00
set -g __fish_git_prompt_color $nightfox_blue
2023-09-04 16:14:08 +02:00
set -g __fish_git_prompt_showstashstate 1
set -g __fish_git_prompt_showdirtystate 1
set -g __fish_git_prompt_showuntrackedfiles 1
set -g __fish_git_prompt_showupstream informative
set -g __fish_git_prompt_showcolorhints 1
set -g __fish_git_prompt_use_informative_chars 0
set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_char_stateseparator '|'
set -g __fish_git_prompt_char_cleanstate 'C'
set -g __fish_git_prompt_char_dirtystate "+"
set -g __fish_git_prompt_char_invalidstate "#"
set -g __fish_git_prompt_char_stagedstate "S"
set -g __fish_git_prompt_char_stashstate "\$"
set -g __fish_git_prompt_char_upstream_ahead "↑"
set -g __fish_git_prompt_char_upstream_behind "↓"
set -g __fish_git_prompt_char_upstream_diverged "!="
set -g __fish_git_prompt_char_upstream_equal "=="
set -g __fish_git_prompt_color_branch -b $color_vcs_bg $color_vcs_text
2023-09-06 03:06:11 +02:00
set -g __fish_git_prompt_color_branch_detached -b $color_vcs_bg $nightfox_red
set -g __fish_git_prompt_color_branch_dirty -b $color_vcs_bg $nightfox_blue
set -g __fish_git_prompt_color_branch_staged -b $color_vcs_bg $nightfox_green
2023-09-04 16:14:08 +02:00
set -g __fish_git_prompt_color_flags -b $color_vcs_bg $color_vcs_text
set -g __fish_git_prompt_color -b $color_vcs_bg $color_vcs_text
set -g __fish_git_prompt_color_prefix -b $color_vcs_bg $color_vcs_text
set -g __fish_git_prompt_color_suffix -b $color_vcs_bg $color_vcs_text
2023-09-06 03:06:11 +02:00
set -g __fish_git_prompt_color_bare -b $color_vcs_bg $nightfox_magenta --bold
set -g __fish_git_prompt_color_merging -b $color_vcs_bg $nightfox_red --bold
2023-09-04 16:14:08 +02:00
set -g __fish_git_prompt_color_cleanstate -b $color_vcs_bg $color_vcs_text --bold
2023-09-06 03:06:11 +02:00
set -g __fish_git_prompt_color_dirtystate -b $color_vcs_bg $nightfox_blue --bold
set -g __fish_git_prompt_color_invalidstate -b $color_vcs_bg $nightfox_red --bold
set -g __fish_git_prompt_color_stagedstate -b $color_vcs_bg $nightfox_green --bold
set -g __fish_git_prompt_color_stashstate -b $color_vcs_bg $nightfox_orange --bold
set -g __fish_git_prompt_color_untrackedfiles -b $color_vcs_bg $nightfox_blue --bold
2023-09-04 16:14:08 +02:00
set -g __fish_git_prompt_color_upstream -b $color_vcs_bg $color_vcs_text --bold
set -g __fish_git_prompt_color_prefix_done $normal
set -g __fish_git_prompt_color_bare_done $normal
set -g __fish_git_prompt_color_merging_done $normal
set -g __fish_git_prompt_color_cleanstate_done $normal
set -g __fish_git_prompt_color_dirtystate_done $normal
set -g __fish_git_prompt_color_invalidstate_done $normal
set -g __fish_git_prompt_color_stagedstate_done $normal
set -g __fish_git_prompt_color_stashstate_done $normal
set -g __fish_git_prompt_color_untrackedfiles_done $normal
set -g __fish_git_prompt_color_upstream_done $normal
# We don't want the leading space.
2023-09-06 02:22:26 +02:00
set -f vcs (fish_vcs_prompt '%s' 2>/dev/null)
2023-09-04 16:14:08 +02:00
# Since we display the prompt on a new line allow the directory names to be longer.
set -q fish_prompt_pwd_dir_length
or set -lx fish_prompt_pwd_dir_length 0
# Color the prompt differently when we're root
if functions -q fish_is_root_user; and fish_is_root_user
if set -q fish_color_cwd_root
2023-09-06 02:22:26 +02:00
set -f color_cwd $fish_color_cwd_root
2023-09-04 16:14:08 +02:00
end
end
2023-09-04 16:14:08 +02:00
# Color the prompt in red on error
if test $last_status -ne 0
2023-09-06 03:06:11 +02:00
set -f color_status $nightfox_red
2023-10-02 00:57:35 +02:00
set -f prompt_status "fish✗" $last_status
2023-09-04 16:14:08 +02:00
end
2023-09-06 02:22:26 +02:00
set -f string_env ""
set -f string_venv ""
set -f string_rbenv ""
2023-09-06 02:32:26 +02:00
set -f string_nvm (nvm current 2>/dev/null)
2023-09-06 02:22:26 +02:00
if command -q rbenv
2023-09-06 02:32:26 +02:00
set -f string_rbenv (rbenv local 2>/dev/null)
2023-09-06 02:22:26 +02:00
if not test -n string_rbenv
2023-09-06 02:32:26 +02:00
set -f string_rbenv (rbenv global 2>/dev/null)
2023-09-06 02:22:26 +02:00
end
if test {"$string_rbenv"} = "system"
set -f string_rbenv ""
end
end
if test {"$string_nvm"} = "system"
set -f string_nvm ""
end
2023-09-04 16:14:08 +02:00
set -q VIRTUAL_ENV_DISABLE_PROMPT
or set -g VIRTUAL_ENV_DISABLE_PROMPT true
set -q VIRTUAL_ENV
2023-09-06 02:22:26 +02:00
and set -f string_venv (string replace -r '.*/' '' -- "$VIRTUAL_ENV")
if test -n {"$string_rbenv"} || test -n {"$string_nvm"} || test -n {"$string_venv"}
set -f string_env "$string_nvm| $string_rbenv| $string_venv"
end
2023-09-04 16:14:08 +02:00
# Do nothing if not in vi mode
if test "$fish_key_bindings" = fish_vi_key_bindings
or test "$fish_key_bindings" = fish_hybrid_key_bindings
switch $fish_bind_mode
case default
2023-09-06 03:06:11 +02:00
set -f color_bind $nightfox_red
2023-09-04 16:14:08 +02:00
set -f char_bind 'N'
case insert
2023-09-06 03:06:11 +02:00
set -f color_bind $nightfox_yellow
2023-09-04 16:14:08 +02:00
set -f char_bind 'I'
case replace_one
2023-09-06 03:06:11 +02:00
set -f color_bind $nightfox_cyan
2023-09-04 16:14:08 +02:00
set -f char_bind 'r'
case replace
2023-09-06 03:06:11 +02:00
set -f color_bind $nightfox_blue
2023-09-04 16:14:08 +02:00
set -f char_bind 'R'
case visual
2023-09-06 03:06:11 +02:00
set -f color_bind $nightfox_magenta
2023-09-04 16:14:08 +02:00
set -f char_bind 'V'
end
end
2023-09-06 02:22:26 +02:00
echo -n -s (prompt_login)
echo -n -s (set_color -b $color_venv $color_text) $string_env
echo -n -s (set_color -b $color_status $color_venv) ''
echo -n -s (set_color -b $color_status $color_text) $prompt_status
echo -n -s (set_color -b normal $color_status) ''
echo $normal
echo -n -s (set_color -b $color_cwd $color_text) (prompt_pwd)
echo -n -s (set_color -b $color_vcs_bg $color_cwd) ''
echo -n -s (set_color -b $color_vcs_bg $color_vcs_text) (fish_vcs_prompt)
echo -n -s (set_color -b normal $color_vcs_bg) '' $normal
2023-10-02 00:57:35 +02:00
echo $normal
2023-09-06 02:22:26 +02:00
echo -n -s (set_color --bold -b $color_bind $color_text) $char_bind
2023-10-02 00:57:35 +02:00
echo -n -s (set_color -b normal $color_bind) ''
echo $normal
end
2023-09-04 16:14:08 +02:00
function fish_right_prompt -d "Right prompt"
end