Repaint all prompts if the variables change

This is a good idea in general and simplifies the Classic + VCS
prompt.
This commit is contained in:
Fabian Homborg 2019-12-01 18:05:57 +01:00
parent 00fc36c3eb
commit d91b0f86f4
2 changed files with 15 additions and 40 deletions

View file

@ -139,7 +139,11 @@ function __fish_config_interactive -d "Initializations that should be performed
# fish_color_cwd{,_root} changes value. Like all event handlers, it can't be
# autoloaded.
#
function __fish_repaint -v fish_color_cwd -v fish_color_cwd_root -d "Event handler, repaints the prompt when fish_color_cwd* changes"
set -l varargs --on-variable fish_key_bindings
for var in user host cwd{,_root} status
set -a varargs --on-variable fish_color_$var
end
function __fish_repaint $varargs -d "Event handler, repaints the prompt when fish_color_cwd* changes"
if status --is-interactive
set -e __fish_prompt_cwd
commandline -f repaint 2>/dev/null

View file

@ -1,5 +1,5 @@
# name: Classic + Vcs
# author: Kevin Ballard
# author: Lily Ballard
# vim: set noet:
function fish_prompt --description 'Write out the prompt'
@ -7,44 +7,15 @@ function fish_prompt --description 'Write out the prompt'
set -l last_status $status
set -l normal (set_color normal)
# Hack; fish_config only copies the fish_prompt function (see #736)
if not set -q -g __fish_classic_git_functions_defined
set -g __fish_classic_git_functions_defined
function __fish_repaint_user --on-variable fish_color_user --description "Event handler, repaint when fish_color_user changes"
if status --is-interactive
commandline -f repaint 2>/dev/null
end
end
function __fish_repaint_host --on-variable fish_color_host --description "Event handler, repaint when fish_color_host changes"
if status --is-interactive
commandline -f repaint 2>/dev/null
end
end
function __fish_repaint_status --on-variable fish_color_status --description "Event handler; repaint when fish_color_status changes"
if status --is-interactive
commandline -f repaint 2>/dev/null
end
end
function __fish_repaint_bind_mode --on-variable fish_key_bindings --description "Event handler; repaint when fish_key_bindings changes"
if status --is-interactive
commandline -f repaint 2>/dev/null
end
end
# initialize our new variables
if not set -q __fish_classic_git_prompt_initialized
set -qU fish_color_user
or set -U fish_color_user -o green
set -qU fish_color_host
or set -U fish_color_host -o cyan
set -qU fish_color_status
or set -U fish_color_status red
set -U __fish_classic_git_prompt_initialized
end
# initialize our new variables
if not set -q __fish_classic_git_prompt_initialized
set -qU fish_color_user
or set -U fish_color_user -o green
set -qU fish_color_host
or set -U fish_color_host -o cyan
set -qU fish_color_status
or set -U fish_color_status red
set -U __fish_classic_git_prompt_initialized
end
set -l color_cwd