diff options
author | Kevin Ballard <kevin@sb.org> | 2014-10-02 14:02:53 -0700 |
---|---|---|
committer | Kevin Ballard <kevin@sb.org> | 2014-10-02 18:41:01 -0700 |
commit | 3f11d90744ef1ab1b32f394d50eb4b911aaf50f3 (patch) | |
tree | df62dbb610c4afbab4c974d99be44c8bb57a6a7e /share/functions/fish_prompt.fish | |
parent | ae7b6156ac136f6cf7c30f5e0aeeda82dfc56af0 (diff) |
# This is a combination of 2 commits.
# The first commit's message is:
Simplify default fish_prompt
No need for the set_color caching now that it's a builtin.
Also simplify the 3 classic prompts in fish_config's sample_prompts set.
Diffstat (limited to 'share/functions/fish_prompt.fish')
-rw-r--r-- | share/functions/fish_prompt.fish | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/share/functions/fish_prompt.fish b/share/functions/fish_prompt.fish index aaa48c68..b4a350b8 100644 --- a/share/functions/fish_prompt.fish +++ b/share/functions/fish_prompt.fish @@ -1,40 +1,27 @@ -# Set the default prompt command. Make sure that every terminal escape -# string has a newline before and after, so that fish will know how -# long it is. +# vim: set noet: +# +# Set the default prompt command. function fish_prompt --description "Write out the prompt" - - # Just calculate these once, to save a few cycles when displaying 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 - if not set -q __fish_prompt_normal - set -g __fish_prompt_normal (set_color normal) - end - + set -l color_cwd + set -l suffix switch $USER - - case root toor - - if not set -q __fish_prompt_cwd - if set -q fish_color_cwd_root - set -g __fish_prompt_cwd (set_color $fish_color_cwd_root) - else - set -g __fish_prompt_cwd (set_color $fish_color_cwd) - end + case root toor + if set -q fish_color_cwd_root + set color_cwd $fish_color_cwd_root + else + set color_cwd $fish_color_cwd end - - echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" '# ' - - case '*' - - if not set -q __fish_prompt_cwd - 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" '> ' - + set suffix '#' + case '*' + set color_cwd $fish_color_cwd + set suffix '>' end -end + echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix " +end |