diff --git a/share/functions/fish_fallback_prompt.fish b/share/functions/fish_fallback_prompt.fish index ae4fa0210..ec5bfb7d5 100644 --- a/share/functions/fish_fallback_prompt.fish +++ b/share/functions/fish_fallback_prompt.fish @@ -3,11 +3,6 @@ # Set the default prompt command. function fish_fallback_prompt --description "A simple fallback prompt without too much color or special characters for linux VTs" - # Just calculate this once, to save a few cycles when displaying the prompt - if not set -q __fish_prompt_hostname - set -g __fish_prompt_hostname (hostname|cut -d . -f 1) - end - set -l color_cwd set -l suffix switch $USER @@ -23,5 +18,5 @@ function fish_fallback_prompt --description "A simple fallback prompt without to set suffix '>' end - echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix " + echo -n -s "$USER" @ (fish_prompt_hostname) ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix " end diff --git a/share/functions/fish_prompt.fish b/share/functions/fish_prompt.fish index b4a350b8f..5a0e6243a 100644 --- a/share/functions/fish_prompt.fish +++ b/share/functions/fish_prompt.fish @@ -3,11 +3,6 @@ # Set the default prompt command. function fish_prompt --description "Write out the prompt" - # Just calculate this once, to save a few cycles when displaying the prompt - if not set -q __fish_prompt_hostname - set -g __fish_prompt_hostname (hostname|cut -d . -f 1) - end - set -l color_cwd set -l suffix switch $USER @@ -23,5 +18,5 @@ function fish_prompt --description "Write out the prompt" set suffix '>' end - echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix " + echo -n -s "$USER" @ (fish_prompt_hostname) ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix " end diff --git a/share/tools/web_config/sample_prompts/classic.fish b/share/tools/web_config/sample_prompts/classic.fish index b092803e4..0be38222b 100644 --- a/share/tools/web_config/sample_prompts/classic.fish +++ b/share/tools/web_config/sample_prompts/classic.fish @@ -1,10 +1,5 @@ # name: Classic function fish_prompt --description "Write out the prompt" - # Just calculate this once, to save a few cycles when displaying the prompt - if not set -q __fish_prompt_hostname - set -g __fish_prompt_hostname (hostname|cut -d . -f 1) - end - set -l color_cwd set -l suffix switch $USER @@ -20,5 +15,5 @@ function fish_prompt --description "Write out the prompt" set suffix '>' end - echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix " + echo -n -s "$USER" @ (fish_prompt_hostname) ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix " end diff --git a/share/tools/web_config/sample_prompts/classic_status.fish b/share/tools/web_config/sample_prompts/classic_status.fish index fe64f7934..a004d6073 100644 --- a/share/tools/web_config/sample_prompts/classic_status.fish +++ b/share/tools/web_config/sample_prompts/classic_status.fish @@ -10,11 +10,6 @@ function fish_prompt --description "Write out the prompt" printf "%s(%d)%s " (set_color red --bold) $last_status (set_color normal) end - # Just calculate this once, to save a few cycles when displaying the prompt - if not set -q __fish_prompt_hostname - set -g __fish_prompt_hostname (hostname|cut -d . -f 1) - end - set -l color_cwd set -l suffix switch $USER @@ -30,5 +25,5 @@ function fish_prompt --description "Write out the prompt" set suffix '>' end - echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix " + echo -n -s "$USER" @ (fish_prompt_hostname) ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix " end diff --git a/share/tools/web_config/sample_prompts/classic_vcs.fish b/share/tools/web_config/sample_prompts/classic_vcs.fish index 755c95027..92513ef10 100644 --- a/share/tools/web_config/sample_prompts/classic_vcs.fish +++ b/share/tools/web_config/sample_prompts/classic_vcs.fish @@ -4,12 +4,6 @@ function fish_prompt --description 'Write out the prompt' set -l last_status $status - - # Just calculate this once, to save a few cycles when displaying the prompt - if not set -q __fish_prompt_hostname - set -g __fish_prompt_hostname (hostname|cut -d . -f 1) - end - set -l normal (set_color normal) # Hack; fish_config only copies the fish_prompt function (see #736) @@ -21,13 +15,13 @@ function fish_prompt --description 'Write out the prompt' 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 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 commandline -f repaint ^/dev/null @@ -69,5 +63,5 @@ function fish_prompt --description 'Write out the prompt' set prompt_status ' ' (set_color $fish_color_status) "[$last_status]" "$normal" end - echo -n -s (set_color $fish_color_user) "$USER" $normal @ (set_color $fish_color_host) "$__fish_prompt_hostname" $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (__fish_vcs_prompt) $normal $prompt_status "> " + echo -n -s (set_color $fish_color_user) "$USER" $normal @ (set_color $fish_color_host) (fish_prompt_hostname) $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (__fish_vcs_prompt) $normal $prompt_status "> " end diff --git a/share/tools/web_config/sample_prompts/debian_chroot.fish b/share/tools/web_config/sample_prompts/debian_chroot.fish index 80acfa9a5..1f6fffe7f 100644 --- a/share/tools/web_config/sample_prompts/debian_chroot.fish +++ b/share/tools/web_config/sample_prompts/debian_chroot.fish @@ -2,12 +2,6 @@ # author: Maurizio De Santis function fish_prompt --description 'Write out the prompt, prepending the Debian chroot environment if present' - - # Just calculate these once, to save a few cycles when displaying the prompt - if not set -q __fish_prompt_hostname - set -g __fish_prompt_hostname (hostname|cut -d . -f 1) - end - if not set -q __fish_prompt_normal set -g __fish_prompt_normal (set_color normal) end @@ -41,7 +35,7 @@ function fish_prompt --description 'Write out the prompt, prepending the Debian end end - echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '# ' + echo -n -s "$USER" @ (fish_prompt_hostname) ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '# ' case '*' @@ -49,7 +43,7 @@ function fish_prompt --description 'Write out the prompt, prepending the Debian set -g __fish_prompt_cwd (set_color $fish_color_cwd) end - echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '> ' + echo -n -s "$USER" @ (fish_prompt_hostname) ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '> ' end end diff --git a/share/tools/web_config/sample_prompts/informative.fish b/share/tools/web_config/sample_prompts/informative.fish index 749d81713..40df49e7e 100644 --- a/share/tools/web_config/sample_prompts/informative.fish +++ b/share/tools/web_config/sample_prompts/informative.fish @@ -6,11 +6,6 @@ function fish_prompt --description 'Write out the prompt' #Save the return status of the previous command set stat $status -# Just calculate these once, to save a few cycles when displaying the prompt - if not set -q __fish_prompt_hostname - set -g __fish_prompt_hostname (hostname|cut -d . -f 1) - end - if not set -q __fish_prompt_normal set -g __fish_prompt_normal (set_color normal) end @@ -37,7 +32,7 @@ if not set -q __fish_prompt_cwd end end -printf '%s@%s %s%s%s# ' $USER $__fish_prompt_hostname "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" +printf '%s@%s %s%s%s# ' $USER (fish_prompt_hostname) "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" case '*' @@ -45,7 +40,7 @@ if not set -q __fish_prompt_cwd set -g __fish_prompt_cwd (set_color $fish_color_cwd) end -printf '[%s] %s%s@%s %s%s %s(%s)%s \f\r> ' (date "+%H:%M:%S") "$__fish_color_blue" $USER $__fish_prompt_hostname "$__fish_prompt_cwd" "$PWD" "$__fish_color_status" "$stat" "$__fish_prompt_normal" +printf '[%s] %s%s@%s %s%s %s(%s)%s \f\r> ' (date "+%H:%M:%S") "$__fish_color_blue" $USER (fish_prompt_hostname) "$__fish_prompt_cwd" "$PWD" "$__fish_color_status" "$stat" "$__fish_prompt_normal" end end diff --git a/share/tools/web_config/sample_prompts/lonetwin.fish b/share/tools/web_config/sample_prompts/lonetwin.fish index d22beff41..4b448d313 100644 --- a/share/tools/web_config/sample_prompts/lonetwin.fish +++ b/share/tools/web_config/sample_prompts/lonetwin.fish @@ -2,11 +2,6 @@ # author: Steve function fish_prompt --description 'Write out the prompt' - # Just calculate these once, to save a few cycles when displaying the prompt - if not set -q __fish_prompt_hostname - set -g __fish_prompt_hostname (hostname -s) - end - if not set -q __fish_prompt_normal set -g __fish_prompt_normal (set_color normal) end @@ -15,6 +10,5 @@ function fish_prompt --description 'Write out the prompt' set -g __fish_prompt_cwd (set_color $fish_color_cwd) end - echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) (__fish_vcs_prompt) "$__fish_prompt_normal" '> ' - + echo -n -s "$USER" @ (fish_prompt_hostname) ' ' "$__fish_prompt_cwd" (prompt_pwd) (__fish_vcs_prompt) "$__fish_prompt_normal" '> ' end diff --git a/share/tools/web_config/sample_prompts/nim.fish b/share/tools/web_config/sample_prompts/nim.fish index 5d2dac394..e9392e13f 100644 --- a/share/tools/web_config/sample_prompts/nim.fish +++ b/share/tools/web_config/sample_prompts/nim.fish @@ -26,7 +26,7 @@ function fish_prompt else set_color -o cyan end - echo -n (hostname) + echo -n (fish_prompt_hostname) set_color -o white #echo -n :(prompt_pwd) echo -n :(pwd|sed "s=$HOME=~=") diff --git a/share/tools/web_config/sample_prompts/pythonista.fish b/share/tools/web_config/sample_prompts/pythonista.fish index ad772e2f7..d4597a25d 100644 --- a/share/tools/web_config/sample_prompts/pythonista.fish +++ b/share/tools/web_config/sample_prompts/pythonista.fish @@ -12,7 +12,7 @@ function fish_prompt printf ' at ' set_color magenta - printf '%s' (hostname|cut -d . -f 1) + echo -n (fish_prompt_hostname) set_color normal printf ' in ' diff --git a/share/tools/web_config/sample_prompts/screen_savvy.fish b/share/tools/web_config/sample_prompts/screen_savvy.fish index 83c7db641..c75b81466 100644 --- a/share/tools/web_config/sample_prompts/screen_savvy.fish +++ b/share/tools/web_config/sample_prompts/screen_savvy.fish @@ -2,8 +2,8 @@ # author: Matthias function fish_prompt -d "Write out the prompt" if test -z $WINDOW - printf '%s%s@%s%s%s%s%s> ' (set_color yellow) (whoami) (set_color purple) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) + printf '%s%s@%s%s%s%s%s> ' (set_color yellow) (whoami) (set_color purple) (fish_prompt_hostname) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) else - printf '%s%s@%s%s%s(%s)%s%s%s> ' (set_color yellow) (whoami) (set_color purple) (hostname|cut -d . -f 1) (set_color white) (echo $WINDOW) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) + printf '%s%s@%s%s%s(%s)%s%s%s> ' (set_color yellow) (whoami) (set_color purple) (fish_prompt_hostname) (set_color white) (echo $WINDOW) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) end end diff --git a/share/tools/web_config/sample_prompts/sorin.fish b/share/tools/web_config/sample_prompts/sorin.fish index cab4b8c58..ad0c89b9d 100644 --- a/share/tools/web_config/sample_prompts/sorin.fish +++ b/share/tools/web_config/sample_prompts/sorin.fish @@ -2,7 +2,7 @@ # author: Ivan Tham function fish_prompt - test $SSH_TTY; and printf (set_color red)(whoami)(set_color white)'@'(set_color yellow)(hostname)' ' + test $SSH_TTY; and printf (set_color red)(whoami)(set_color white)'@'(set_color yellow)(fish_prompt_hostname)' ' test $USER = 'root'; and echo (set_color red)"#" diff --git a/share/tools/web_config/sample_prompts/terlar.fish b/share/tools/web_config/sample_prompts/terlar.fish index d75b17b58..612d50ac5 100644 --- a/share/tools/web_config/sample_prompts/terlar.fish +++ b/share/tools/web_config/sample_prompts/terlar.fish @@ -13,7 +13,7 @@ function fish_prompt --description 'Write out the prompt' # Host set_color $fish_color_host - echo -n (hostname -s) + echo -n (fish_prompt_hostname) set_color normal echo -n ':' diff --git a/share/tools/web_config/sample_prompts/user_host_path.fish b/share/tools/web_config/sample_prompts/user_host_path.fish index de917ee71..b4a1be6a1 100644 --- a/share/tools/web_config/sample_prompts/user_host_path.fish +++ b/share/tools/web_config/sample_prompts/user_host_path.fish @@ -9,5 +9,5 @@ function fish_prompt -d "Write out the prompt" case root toor; set prompt_symbol '#' case '*'; set prompt_symbol '$' end - printf "[%s@%s %s%s%s]%s " $USER (hostname -s) (set_color $fish_color_cwd) $pwd (set_color normal) $prompt_symbol + printf "[%s@%s %s%s%s]%s " $USER (fish_prompt_hostname) (set_color $fish_color_cwd) $pwd (set_color normal) $prompt_symbol end