diff options
-rw-r--r-- | share/tools/web_config/sample_prompts/classic_git.fish | 45 | ||||
-rw-r--r-- | share/tools/web_config/sample_prompts/robbyrussell.fish | 18 |
2 files changed, 36 insertions, 27 deletions
diff --git a/share/tools/web_config/sample_prompts/classic_git.fish b/share/tools/web_config/sample_prompts/classic_git.fish index b09fcef9..0d91f5fe 100644 --- a/share/tools/web_config/sample_prompts/classic_git.fish +++ b/share/tools/web_config/sample_prompts/classic_git.fish @@ -13,6 +13,31 @@ function fish_prompt --description 'Write out the prompt' if not set -q __fish_prompt_normal set -g __fish_prompt_normal (set_color normal) end + + 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 + set -e __fish_prompt_user + commandline -f repaint ^/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 + set -e __fish_prompt_host + commandline -f repaint ^/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 + set -e __fish_prompt_status + commandline -f repaint ^/dev/null + end + end + end set -l delim '>' @@ -54,26 +79,6 @@ function fish_prompt --description 'Write out the prompt' echo -n -s "$__fish_prompt_user" "$USER" "$__fish_prompt_normal" @ "$__fish_prompt_host" "$__fish_prompt_hostname" "$__fish_prompt_normal" ' ' "$__fish_prompt_cwd" (prompt_pwd) (__fish_git_prompt) "$__fish_prompt_normal" "$prompt_status" "$delim" ' ' end -function __fish_repaint_user --on-variable fish_color_user --description "Event handler, repaint when fish_color_user changes" - if status --is-interactive - set -e __fish_prompt_user - commandline -f repaint ^/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 - set -e __fish_prompt_host - commandline -f repaint ^/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 - set -e __fish_prompt_status - commandline -f repaint ^/dev/null - end -end # initialize our new variables # in theory this would be in a fish_prompt event, but this file isn't sourced diff --git a/share/tools/web_config/sample_prompts/robbyrussell.fish b/share/tools/web_config/sample_prompts/robbyrussell.fish index 2493f766..fdc02f32 100644 --- a/share/tools/web_config/sample_prompts/robbyrussell.fish +++ b/share/tools/web_config/sample_prompts/robbyrussell.fish @@ -1,15 +1,19 @@ # name: Robbyrussell # author: Bruno Ferreira Pinto -function _git_branch_name - echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') -end +function fish_prompt -function _is_git_dirty - echo (git status -s --ignore-submodules=dirty ^/dev/null) -end + if not set -q -g __fish_robbyrussell_functions_defined + set -g __fish_robbyrussell_functions_defined + function _git_branch_name + echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') + end + + function _is_git_dirty + echo (git status -s --ignore-submodules=dirty ^/dev/null) + end + end -function fish_prompt set -l cyan (set_color -o cyan) set -l yellow (set_color -o yellow) set -l red (set_color -o red) |