mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 12:41:08 +08:00
Ugly hack to move functions in sample prompts inside fish_prompt to address #736
This commit is contained in:
parent
622efba247
commit
8befc474c1
|
@ -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
|
||||
|
|
|
@ -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 _is_git_dirty
|
||||
echo (git status -s --ignore-submodules=dirty ^/dev/null)
|
||||
end
|
||||
|
||||
function fish_prompt
|
||||
|
||||
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
|
||||
|
||||
set -l cyan (set_color -o cyan)
|
||||
set -l yellow (set_color -o yellow)
|
||||
set -l red (set_color -o red)
|
||||
|
|
Loading…
Reference in New Issue
Block a user