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

187 lines
7.0 KiB
Fish
Executable File

# 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'
set -f color_venv 71839b
set -f color_bind normal
set -f color_text 131a24
set -f color_magenta 9d79d6
set -f color_blue 719cd6
set -f color_cyan 63cdcf
set -f color_green 81b29a
set -f color_yellow dbc074
set -f color_orange f4a261
set -f color_red c94f6d
set -f color_pink d67ad2
set -f color_white dfdfe0
set -f color_bg0 131a24
set -f color_bg1 192330
set -f color_bg2 212e3f
set -f color_bg3 29394f
set -f color_bg4 39506d
set -f color_sel0 2b3b51
set -f color_sel1 3c5372
set -f color_status $color_green
set -f color_bind $color_green
set -f color_cwd $fish_color_cwd
set -f color_vcs_text $color_yellow
set -f color_vcs_bg $color_bg2
set -f char_bind 'E'
set -f char_user_cwd '%'
set -f char_root_cwd '#'
set -f last_status $status
set -f normal (set_color normal)
set -f prompt_status "✔"
set -g __fish_git_prompt_color $color_blue
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
set -g __fish_git_prompt_color_branch_detached -b $color_vcs_bg $color_red
set -g __fish_git_prompt_color_branch_dirty -b $color_vcs_bg $color_blue
set -g __fish_git_prompt_color_branch_staged -b $color_vcs_bg $color_green
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
set -g __fish_git_prompt_color_bare -b $color_vcs_bg $color_magenta --bold
set -g __fish_git_prompt_color_merging -b $color_vcs_bg $color_red --bold
set -g __fish_git_prompt_color_cleanstate -b $color_vcs_bg $color_vcs_text --bold
set -g __fish_git_prompt_color_dirtystate -b $color_vcs_bg $color_blue --bold
set -g __fish_git_prompt_color_invalidstate -b $color_vcs_bg $color_red --bold
set -g __fish_git_prompt_color_stagedstate -b $color_vcs_bg $color_green --bold
set -g __fish_git_prompt_color_stashstate -b $color_vcs_bg $color_orange --bold
set -g __fish_git_prompt_color_untrackedfiles -b $color_vcs_bg $color_blue --bold
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.
set -f vcs (fish_vcs_prompt '%s' 2>/dev/null)
# 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
set -f suffix $char_user_cwd
if functions -q fish_is_root_user; and fish_is_root_user
if set -q fish_color_cwd_root
set -f color_cwd $fish_color_cwd_root
end
set -f suffix $char_root_cwd
end
# Color the prompt in red on error
if test $last_status -ne 0
set -f color_status $color_red
set -f prompt_status "[" $last_status "]"
end
set -f string_env ""
set -f string_venv ""
set -f string_rbenv ""
set -f string_nvm (nvm current 2>/dev/null)
if command -q rbenv
set -f string_rbenv (rbenv local 2>/dev/null)
if not test -n string_rbenv
set -f string_rbenv (rbenv global 2>/dev/null)
end
if test {"$string_rbenv"} = "system"
set -f string_rbenv ""
end
end
if test {"$string_nvm"} = "system"
set -f string_nvm ""
end
set -q VIRTUAL_ENV_DISABLE_PROMPT
or set -g VIRTUAL_ENV_DISABLE_PROMPT true
set -q VIRTUAL_ENV
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
# 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
set -f color_bind $color_red
set -f char_bind 'N'
case insert
set -f color_bind $color_yellow
set -f char_bind 'I'
case replace_one
set -f color_bind $color_cyan
set -f char_bind 'r'
case replace
set -f color_bind $color_blue
set -f char_bind 'R'
case visual
set -f color_bind $color_magenta
set -f char_bind 'V'
end
end
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
echo -s $normal
echo -n -s (set_color --bold -b $color_bind $color_text) $char_bind
echo -n -s (set_color -b $color_cwd $color_bind) ''
echo -n -s (set_color -b $color_cwd $color_text) $suffix
echo -n -s (set_color -b normal $color_cwd) ' ' $normal
end
function fish_right_prompt -d "Right prompt"
end