Stop caching set_color output in rest of prompts

No more __fish_prompt_* variables.
This commit is contained in:
Aaron Gyes 2019-04-09 03:37:10 -07:00
parent 5f7f4c638f
commit 3b97e2d7ec
4 changed files with 11 additions and 44 deletions

View file

@ -2,14 +2,6 @@
# author: Maurizio De Santis # author: Maurizio De Santis
function fish_prompt --description 'Write out the prompt, prepending the Debian chroot environment if present' function fish_prompt --description 'Write out the prompt, prepending the Debian chroot environment if present'
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
if not set -q __fish_prompt_chroot_env
set -g __fish_prompt_chroot_env (set_color yellow)
end
# Set variable identifying the chroot you work in (used in the prompt below) # Set variable identifying the chroot you work in (used in the prompt below)
if not set -q debian_chroot if not set -q debian_chroot
and test -r /etc/debian_chroot and test -r /etc/debian_chroot
@ -23,27 +15,19 @@ function fish_prompt --description 'Write out the prompt, prepending the Debian
# Prepend the chroot environment if present # Prepend the chroot environment if present
if set -q __fish_debian_chroot_prompt if set -q __fish_debian_chroot_prompt
echo -n -s "$__fish_prompt_chroot_env" "$__fish_debian_chroot_prompt" "$__fish_prompt_normal" ' ' echo -n -s (set_color yellow) "$__fish_debian_chroot_prompt" (set_color normal) ' '
end end
switch "$USER" switch "$USER"
case root toor case root toor
if not set -q __fish_prompt_cwd echo -n -s "$USER" @ (prompt_hostname) ' ' (set -q fish_color_cwd_root
if set -q fish_color_cwd_root and set_color $fish_color_cwd_root
set -g __fish_prompt_cwd (set_color $fish_color_cwd_root) or set_color $fish_color_cwd) (prompt_pwd) \
else (set_color normal) '# '
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
end
end
echo -n -s "$USER" @ (prompt_hostname) ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '# '
case '*' case '*'
if not set -q __fish_prompt_cwd echo -n -s "$USER" @ (prompt_hostname) ' ' (set_color $fish_color_cwd) (prompt_pwd) \
set -g __fish_prompt_cwd (set_color $fish_color_cwd) (set_color normal) '> '
end
echo -n -s "$USER" @ (prompt_hostname) ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '> '
end end
end end

View file

@ -15,9 +15,9 @@ function fish_prompt --description 'Informative prompt'
switch "$USER" switch "$USER"
case root toor case root toor
printf '%s@%s %s%s%s# ' $USER (prompt_hostname) (set -q fish_color_cwd_root && \ printf '%s@%s %s%s%s# ' $USER (prompt_hostname) (set -q fish_color_cwd_root
set_color $fish_color_cwd_root || \ and set_color $fish_color_cwd_root
set_color $fish_color_cwd) \ or set_color $fish_color_cwd) \
(prompt_pwd) (set_color normal) (prompt_pwd) (set_color normal)
case '*' case '*'
set -l pipestatus_string (__fish_print_pipestatus "[" "] " "|" (set_color yellow) \ set -l pipestatus_string (__fish_print_pipestatus "[" "] " "|" (set_color yellow) \

View file

@ -1,8 +1,6 @@
# name: Informative Vcs # name: Informative Vcs
# author: Mariusz Smykula <mariuszs at gmail.com> # author: Mariusz Smykula <mariuszs at gmail.com>
function fish_prompt --description 'Write out the prompt' function fish_prompt --description 'Write out the prompt'
set -l last_pipestatus $pipestatus set -l last_pipestatus $pipestatus
set -l last_status $status set -l last_status $status
@ -13,7 +11,6 @@ function fish_prompt --description 'Write out the prompt'
if not set -q __fish_git_prompt_hide_untrackedfiles if not set -q __fish_git_prompt_hide_untrackedfiles
set -g __fish_git_prompt_hide_untrackedfiles 1 set -g __fish_git_prompt_hide_untrackedfiles 1
end end
if not set -q __fish_git_prompt_color_branch if not set -q __fish_git_prompt_color_branch
set -g __fish_git_prompt_color_branch magenta --bold set -g __fish_git_prompt_color_branch magenta --bold
end end
@ -29,7 +26,6 @@ function fish_prompt --description 'Write out the prompt'
if not set -q __fish_git_prompt_char_upstream_prefix if not set -q __fish_git_prompt_char_upstream_prefix
set -g __fish_git_prompt_char_upstream_prefix "" set -g __fish_git_prompt_char_upstream_prefix ""
end end
if not set -q __fish_git_prompt_char_stagedstate if not set -q __fish_git_prompt_char_stagedstate
set -g __fish_git_prompt_char_stagedstate "●" set -g __fish_git_prompt_char_stagedstate "●"
end end
@ -45,7 +41,6 @@ function fish_prompt --description 'Write out the prompt'
if not set -q __fish_git_prompt_char_cleanstate if not set -q __fish_git_prompt_char_cleanstate
set -g __fish_git_prompt_char_cleanstate "✔" set -g __fish_git_prompt_char_cleanstate "✔"
end end
if not set -q __fish_git_prompt_color_dirtystate if not set -q __fish_git_prompt_color_dirtystate
set -g __fish_git_prompt_color_dirtystate blue set -g __fish_git_prompt_color_dirtystate blue
end end
@ -62,10 +57,6 @@ function fish_prompt --description 'Write out the prompt'
set -g __fish_git_prompt_color_cleanstate green --bold set -g __fish_git_prompt_color_cleanstate green --bold
end end
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
set -l color_cwd set -l color_cwd
set -l prefix set -l prefix
set -l suffix set -l suffix

View file

@ -2,13 +2,5 @@
# author: Steve # author: Steve
function fish_prompt --description 'Write out the prompt' function fish_prompt --description 'Write out the prompt'
if not set -q __fish_prompt_normal echo -n -s "$USER" @ (prompt_hostname) ' ' (set_color $fish_color_cwd) (prompt_pwd) (fish_vcs_prompt) (set_color normal) '> '
set -g __fish_prompt_normal (set_color normal)
end
if not set -q __fish_prompt_cwd
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
end
echo -n -s "$USER" @ (prompt_hostname) ' ' "$__fish_prompt_cwd" (prompt_pwd) (fish_vcs_prompt) "$__fish_prompt_normal" '> '
end end