From e067bba8a42d7de7f8db1d48eb660a7f16c42d8f Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 20 Feb 2018 22:15:23 -0800 Subject: [PATCH 01/20] words --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 98301f3..be0d169 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -340,7 +340,7 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a no # # Note that iff the current user is root and '/' is not writeable by root this # will be wrong. But I can't think of a single reason that would happen, and - # this way is 99.5% faster to check it this way, so that's a tradeoff I'm + # it is literally 99.5% faster to check it this way, so that's a tradeoff I'm # willing to make. [ -w / ] and [ (id -u) -eq 0 ] From da2cd2eac4148d492a7b7ae2067dd610072bbf8f Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 20 Feb 2018 22:16:17 -0800 Subject: [PATCH 02/20] use index for git staged status hashtag premature optimizations --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index be0d169..918258d 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -720,7 +720,7 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st end end - set -l staged (command git diff --cached --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$__bobthefish_git_staged_glyph") + set -l staged (command git diff-index --cached --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$__bobthefish_git_staged_glyph") set -l stashed (command git rev-parse --verify --quiet refs/stash >/dev/null; and echo -n "$__bobthefish_git_stashed_glyph") set -l ahead (__bobthefish_git_ahead) From d1731ae1e13e76cf362f1459405b9c5aa827ea59 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 20 Feb 2018 22:20:50 -0800 Subject: [PATCH 03/20] huh. weird that we were still using glyphs there. --- fish_prompt.fish | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 918258d..baa54ab 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -334,7 +334,7 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a no # Last exit was nonzero [ $last_status -ne 0 ] - and set nonzero $__bobthefish_nonzero_exit_glyph + and set nonzero 1 # If superuser (uid == 0) # @@ -344,11 +344,11 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a no # willing to make. [ -w / ] and [ (id -u) -eq 0 ] - and set superuser $__bobthefish_superuser_glyph + and set superuser 1 # Jobs display jobs -p >/dev/null - and set bg_jobs $__bobthefish_bg_job_glyph + and set bg_jobs 1 if [ "$nonzero" -o "$superuser" -o "$bg_jobs" ] __bobthefish_start_segment $__color_initial_segment_exit From 180f251189f1e3b298568af3af3e82482123febd Mon Sep 17 00:00:00 2001 From: Philip Fulgham Date: Wed, 21 Feb 2018 01:25:19 -0500 Subject: [PATCH 04/20] Add verbose option for Git dirty state (#133) * Add verbose option for Git dirty state * Simplify git dirty verbose setting check --- README.md | 1 + fish_prompt.fish | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 3b36615..ad042b8 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ set -g theme_display_git no set -g theme_display_git_dirty no set -g theme_display_git_untracked no set -g theme_display_git_ahead_verbose yes +set -g theme_display_git_dirty_verbose yes set -g theme_git_worktree_support yes set -g theme_display_vagrant yes set -g theme_display_docker_machine no diff --git a/fish_prompt.fish b/fish_prompt.fish index baa54ab..827587b 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -21,6 +21,7 @@ # set -g theme_display_git_dirty no # set -g theme_display_git_untracked no # set -g theme_display_git_ahead_verbose yes +# set -g theme_display_git_dirty_verbose yes # set -g theme_git_worktree_support yes # set -g theme_display_vagrant yes # set -g theme_display_docker_machine no @@ -239,6 +240,12 @@ function __bobthefish_git_ahead_verbose -S -d 'Print a more verbose ahead/behind end end +function __bobthefish_git_dirty_verbose -S -d 'Print a more verbose dirty state for the current working tree' + set -l changes (command git diff --numstat | awk '{ added += $1; removed += $2 } END { print "+" added "/-" removed }') + [ $status != 0 ]; and return + + echo "$changes " +end # ============================== # Segment functions @@ -717,6 +724,9 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st set -l show_dirty (command git config --bool bash.showDirtyState ^/dev/null) if [ "$show_dirty" != 'false' ] set dirty (command git diff --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$__bobthefish_git_dirty_glyph") + if [ "$dirty" -a "$theme_display_git_dirty_verbose" = 'yes' ] + set dirty "$dirty"(__bobthefish_git_dirty_verbose) + end end end From 8bd72dbe19779aeb1c3de86771d5279b7c714115 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 20 Feb 2018 22:30:19 -0800 Subject: [PATCH 05/20] Match "or return" style used elsewhere --- fish_prompt.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 827587b..71ad22a 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -222,7 +222,7 @@ end function __bobthefish_git_ahead_verbose -S -d 'Print a more verbose ahead/behind state for the current branch' set -l commits (command git rev-list --left-right '@{upstream}...HEAD' ^/dev/null) - [ $status != 0 ]; and return + or return set -l behind (count (for arg in $commits; echo $arg; end | command grep '^<')) set -l ahead (count (for arg in $commits; echo $arg; end | command grep -v '^<')) @@ -242,7 +242,7 @@ end function __bobthefish_git_dirty_verbose -S -d 'Print a more verbose dirty state for the current working tree' set -l changes (command git diff --numstat | awk '{ added += $1; removed += $2 } END { print "+" added "/-" removed }') - [ $status != 0 ]; and return + or return echo "$changes " end From 523f7d916a80d5105f16db5298047b40248a1e75 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 20 Feb 2018 22:33:51 -0800 Subject: [PATCH 06/20] Omit +0 and -0 from verbose dirty state --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 71ad22a..175fdcc 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -244,7 +244,7 @@ function __bobthefish_git_dirty_verbose -S -d 'Print a more verbose dirty state set -l changes (command git diff --numstat | awk '{ added += $1; removed += $2 } END { print "+" added "/-" removed }') or return - echo "$changes " + echo "$changes " | string replace '+0/' '' | string replace '/-0 ' ' ' end # ============================== From dd3d58ac5eaea7295cfd75bd285f3fb8e1d014e7 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Wed, 21 Feb 2018 09:46:01 -0800 Subject: [PATCH 07/20] Fix regression in "staged" git flag Fixes #134 --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 175fdcc..852996c 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -730,7 +730,7 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st end end - set -l staged (command git diff-index --cached --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$__bobthefish_git_staged_glyph") + set -l staged (command git diff-index --cached --no-ext-diff --quiet --exit-code HEAD ^/dev/null; or echo -n "$__bobthefish_git_staged_glyph") set -l stashed (command git rev-parse --verify --quiet refs/stash >/dev/null; and echo -n "$__bobthefish_git_stashed_glyph") set -l ahead (__bobthefish_git_ahead) From e3d4545f746c902ea1e2415f33a754076bcf8daa Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Wed, 21 Feb 2018 09:56:53 -0800 Subject: [PATCH 08/20] Nope. That one didn't work in empty repos. Oh well. --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 852996c..be4ee2a 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -730,7 +730,7 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st end end - set -l staged (command git diff-index --cached --no-ext-diff --quiet --exit-code HEAD ^/dev/null; or echo -n "$__bobthefish_git_staged_glyph") + set -l staged (command git diff --cached --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$__bobthefish_git_staged_glyph") set -l stashed (command git rev-parse --verify --quiet refs/stash >/dev/null; and echo -n "$__bobthefish_git_stashed_glyph") set -l ahead (__bobthefish_git_ahead) From 348666beaf8520d39fe639637c02786b589ebc52 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 24 Feb 2018 10:29:21 -0800 Subject: [PATCH 09/20] Better +/-0 filtering Fixes #135 --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index be4ee2a..67b38c9 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -244,7 +244,7 @@ function __bobthefish_git_dirty_verbose -S -d 'Print a more verbose dirty state set -l changes (command git diff --numstat | awk '{ added += $1; removed += $2 } END { print "+" added "/-" removed }') or return - echo "$changes " | string replace '+0/' '' | string replace '/-0 ' ' ' + echo "$changes " | string replace -r '(\+0/(-0)?|/-0)' '' end # ============================== From 39d2739fb7a652cd638ed73ef1acdc276471af0c Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Thu, 1 Mar 2018 15:51:03 -0800 Subject: [PATCH 10/20] Fix python version detection with pypy (probably) See #137 --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 67b38c9..0a3f463 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -650,7 +650,7 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' end function __bobthefish_virtualenv_python_version -S -d 'Get current Python version' - switch (python --version ^| tr '\n' ' ') + switch (python --version ^&1 | tr '\n' ' ') case 'Python 2*PyPy*' echo $__bobthefish_pypy_glyph case 'Python 3*PyPy*' From e57a8f344c58fcb4603b73562b770972b09176ab Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 4 Mar 2018 03:54:51 +0000 Subject: [PATCH 11/20] Support hiding "master" branch name. I've been using this for a bit, and I'm starting to think this should be the default, so I might switch it from opt-in to opt-out at some point :) --- fish_prompt.fish | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 0a3f463..040c5c6 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -22,6 +22,7 @@ # set -g theme_display_git_untracked no # set -g theme_display_git_ahead_verbose yes # set -g theme_display_git_dirty_verbose yes +# set -g theme_display_git_master_branch no # set -g theme_git_worktree_support yes # set -g theme_display_vagrant yes # set -g theme_display_docker_machine no @@ -56,9 +57,14 @@ function __bobthefish_dirname -d 'basically dirname, but faster' end function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' - set -l ref (command git symbolic-ref HEAD ^/dev/null) - and string replace 'refs/heads/' "$__bobthefish_branch_glyph " $ref - and return + set -l ref (command git symbolic-ref HEAD ^/dev/null); and begin + [ "$theme_display_git_master_branch" = 'no' -a "$ref" = 'refs/heads/master' ] + and echo $__bobthefish_branch_glyph + and return + + string replace 'refs/heads/' "$__bobthefish_branch_glyph " $ref + and return + end set -l tag (command git describe --tags --exact-match ^/dev/null) and echo "$__bobthefish_tag_glyph $tag" From 4ac7f3c5d7ff9f75546c8382297622345e819ea6 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Wed, 21 Mar 2018 06:38:08 -0700 Subject: [PATCH 12/20] Switch "hide git master branch" logic from opt-in to opt-out This is a better default. --- README.md | 1 + fish_prompt.fish | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad042b8..db0de0f 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ set -g theme_display_git_dirty no set -g theme_display_git_untracked no set -g theme_display_git_ahead_verbose yes set -g theme_display_git_dirty_verbose yes +set -g theme_display_git_master_branch yes set -g theme_git_worktree_support yes set -g theme_display_vagrant yes set -g theme_display_docker_machine no diff --git a/fish_prompt.fish b/fish_prompt.fish index 040c5c6..fd09763 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -22,7 +22,7 @@ # set -g theme_display_git_untracked no # set -g theme_display_git_ahead_verbose yes # set -g theme_display_git_dirty_verbose yes -# set -g theme_display_git_master_branch no +# set -g theme_display_git_master_branch yes # set -g theme_git_worktree_support yes # set -g theme_display_vagrant yes # set -g theme_display_docker_machine no @@ -58,7 +58,7 @@ end function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' set -l ref (command git symbolic-ref HEAD ^/dev/null); and begin - [ "$theme_display_git_master_branch" = 'no' -a "$ref" = 'refs/heads/master' ] + [ "$theme_display_git_master_branch" != 'yes' -a "$ref" = 'refs/heads/master' ] and echo $__bobthefish_branch_glyph and return From 0cc32a558550c4d6099730d0b1c292b53d6637f0 Mon Sep 17 00:00:00 2001 From: remche Date: Wed, 21 Mar 2018 15:08:21 +0100 Subject: [PATCH 13/20] adding desk prompt (#132) A prompt segment for desk shell environment. https://github.com/jamesob/desk --- fish_prompt.fish | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index fd09763..3062367 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -686,6 +686,13 @@ function __bobthefish_prompt_virtualgo -S -d 'Display current Go virtual environ set_color normal end +function __bobthefish_prompt_desk -S -d 'Display current desk environment' + [ "$theme_display_desk" = 'no' -o -z "$DESK_ENV" ]; and return + __bobthefish_start_segment $__color_desk + echo -ns $__bobthefish_desk_glyph ' ' (basename -a -s ".fish" "$DESK_ENV") ' ' + set_color normal +end + # ============================== # VCS segments @@ -947,7 +954,11 @@ function __bobthefish_maybe_display_colors -S echo -ns $__bobthefish_go_glyph virtualgo ' ' __bobthefish_finish_segments - echo -e "\n" + __bobthefish_start_segment $__color_desk + echo -ns $__bobthefish_desk_glyph desk ' ' + __bobthefish_finish_segments + + echo -e "\n" end @@ -983,6 +994,9 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set -l __bobthefish_ruby_glyph '' set -l __bobthefish_go_glyph '' + # Desk glyphs + set -l __bobthefish_desk_glyph \u25F2 + # Vagrant glyphs set -l __bobthefish_vagrant_running_glyph \u2191 # ↑ 'running' set -l __bobthefish_vagrant_poweroff_glyph \u2193 # ↓ 'poweroff' @@ -1090,6 +1104,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' # set -g __color_rvm af0000 cccccc --bold # set -g __color_virtualfish 005faf cccccc --bold # set -g __color_virtualgo 005faf cccccc --bold + # set -g __color_desk 005faf cccccc --bold case 'terminal' 'terminal-dark*' set -l colorfg black @@ -1119,6 +1134,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm brmagenta $colorfg --bold set __color_virtualfish brblue $colorfg --bold set __color_virtualgo brblue $colorfg --bold + set __color_desk brblue $colorfg --bold case 'terminal-light*' set -l colorfg white @@ -1148,6 +1164,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm brmagenta $colorfg --bold set __color_virtualfish brblue $colorfg --bold set __color_virtualgo brblue $colorfg --bold + set __color_desk brblue $colorfg --bold case 'terminal2' 'terminal2-dark*' set -l colorfg black @@ -1177,6 +1194,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm brmagenta $colorfg --bold set __color_virtualfish brblue $colorfg --bold set __color_virtualgo brblue $colorfg --bold + set __color_desk brblue $colorfg --bold case 'terminal2-light*' set -l colorfg white @@ -1206,6 +1224,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm brmagenta $colorfg --bold set __color_virtualfish brblue $colorfg --bold set __color_virtualgo brblue $colorfg --bold + set __color_desk brblue $colorfg --bold case 'zenburn' set -l grey 333333 # a bit darker than normal zenburn grey @@ -1241,6 +1260,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm $red $grey --bold set __color_virtualfish $blue $grey --bold set __color_virtualgo $blue $grey --bold + set __color_desk $blue $grey --bold case 'base16-light' set -l base00 181818 @@ -1333,6 +1353,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm $base08 $colorfg --bold set __color_virtualfish $base0D $colorfg --bold set __color_virtualgo $base0D $colorfg --bold + set __color_desk $base0D $colorfg --bold case 'solarized-light' set -l base03 002b36 @@ -1379,6 +1400,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm $red $colorfg --bold set __color_virtualfish $cyan $colorfg --bold set __color_virtualgo $cyan $colorfg --bold + set __color_desk $cyan $colorfg --bold case 'solarized' 'solarized-dark' set -l base03 002b36 @@ -1425,6 +1447,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm $red $colorfg --bold set __color_virtualfish $cyan $colorfg --bold set __color_virtualgo $cyan $colorfg --bold + set __color_desk $cyan $colorfg --bold case 'light' # light medium dark @@ -1464,6 +1487,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm $ruby_red $grey[1] --bold set __color_virtualfish $blue[2] $grey[1] --bold set __color_virtualgo $blue[2] $grey[1] --bold + set __color_desk $blue[2] $grey[1] --bold case 'gruvbox' # light medium dark darkest @@ -1502,6 +1526,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm $red[2] $fg[2] --bold set __color_virtualfish $blue[2] $fg[2] --bold set __color_virtualgo $blue[2] $fg[2] --bold + set __color_desk $blue[2] $fg[2] --bold case '*' # default dark theme # light medium dark @@ -1541,6 +1566,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_rvm $ruby_red $grey[1] --bold set __color_virtualfish $blue[2] $grey[1] --bold set __color_virtualgo $blue[2] $grey[1] --bold + set __color_desk $blue[2] $grey[1] --bold end # Start each line with a blank slate @@ -1562,6 +1588,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' __bobthefish_prompt_user # Virtual environments + __bobthefish_prompt_desk __bobthefish_prompt_rubies __bobthefish_prompt_virtualfish __bobthefish_prompt_virtualgo From c6d8357a91d28959275363f6c093b3fdfa629276 Mon Sep 17 00:00:00 2001 From: Alberto Cavalin Date: Fri, 23 Mar 2018 07:01:39 +0100 Subject: [PATCH 14/20] fish_prompt: fix __bobthefish_rvm_info for both rvm installation types (#140) --- fish_prompt.fish | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 3062367..1f29789 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -583,8 +583,12 @@ function __bobthefish_rvm_parse_ruby -S -a ruby_string scope -d 'Parse RVM Ruby end function __bobthefish_rvm_info -S -d 'Current Ruby information from RVM' + # look for rvm install path + set -q rvm_path + or set -l rvm_path ~/.rvm /usr/local/rvm + # More `sed`/`grep`/`cut` magic... - set -l __rvm_default_ruby (grep GEM_HOME ~/.rvm/environments/default | sed -e"s/'//g" | sed -e's/.*\///') + set -l __rvm_default_ruby (grep GEM_HOME $rvm_path/environments/default | sed -e"s/'//g" | sed -e's/.*\///') set -l __rvm_current_ruby (rvm-prompt i v g) [ "$__rvm_default_ruby" = "$__rvm_current_ruby" ]; and return From b579292c2285c7d6158a72277d1b82ab45df4ff3 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Thu, 22 Mar 2018 23:02:51 -0700 Subject: [PATCH 15/20] Add the dev null redirect missed in #140 --- fish_prompt.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 1f29789..455b44e 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -586,9 +586,9 @@ function __bobthefish_rvm_info -S -d 'Current Ruby information from RVM' # look for rvm install path set -q rvm_path or set -l rvm_path ~/.rvm /usr/local/rvm - + # More `sed`/`grep`/`cut` magic... - set -l __rvm_default_ruby (grep GEM_HOME $rvm_path/environments/default | sed -e"s/'//g" | sed -e's/.*\///') + set -l __rvm_default_ruby (grep GEM_HOME $rvm_path/environments/default ^/dev/null | sed -e"s/'//g" | sed -e's/.*\///') set -l __rvm_current_ruby (rvm-prompt i v g) [ "$__rvm_default_ruby" = "$__rvm_current_ruby" ]; and return From 3b0c6929fff233fcae8a4f8ec35d101e9cf0df61 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 25 Mar 2018 08:58:01 -0700 Subject: [PATCH 16/20] What's up. --- fish_greeting.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_greeting.fish b/fish_greeting.fish index ca611e1..25f44c3 100644 --- a/fish_greeting.fish +++ b/fish_greeting.fish @@ -1,4 +1,4 @@ -function fish_greeting -d "what's up, fish?" +function fish_greeting -d "What's up, fish?" set_color $fish_color_autosuggestion uname -nmsr uptime From 5acaae3f62e2acef6133542a56eeaf0ba7e33db4 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 25 Mar 2018 15:50:43 +0000 Subject: [PATCH 17/20] Improved color scheme handling. - Improve performance significantly in the base case (i.e. when git or something isn't slowing it down anyway). - Make `bobthefish_display_colors` a non-underscore function. It's meant for public use :) - Support previewing _different_ color schemes via `bobthefish_display_colors`. Pass a color scheme name, or `--all` to preview everything. - Make color overrides a bit fishier: use a `bobthefish_colors` function to override color schemes, rather than declaring a whole pile of variables. - Add support for a base color scheme in `bobthefish_colors`, in case you don't want to override everything. - Add a deprecation notice with upgrade instructions for users with old-style custom color schemes. --- README.md | 4 +- fish_prompt.fish | 882 ++------------------- functions/__bobthefish_colors.fish | 534 +++++++++++++ functions/__bobthefish_display_colors.fish | 3 + functions/__bobthefish_glyphs.fish | 89 +++ functions/bobthefish_display_colors.fish | 132 +++ 6 files changed, 847 insertions(+), 797 deletions(-) create mode 100644 functions/__bobthefish_colors.fish create mode 100644 functions/__bobthefish_display_colors.fish create mode 100644 functions/__bobthefish_glyphs.fish create mode 100644 functions/bobthefish_display_colors.fish diff --git a/README.md b/README.md index db0de0f..73e8d26 100644 --- a/README.md +++ b/README.md @@ -128,8 +128,8 @@ set -g theme_newline_cursor yes | ![base16][base16] | ![base16-light][base16-light] | | ![zenburn][zenburn] | ![terminal-dark][terminal-dark] | -You can use the function `__bobthefish_display_colors` to preview the prompts in -the current theme. +You can use the function `bobthefish_display_colors` to preview the prompts in +any color scheme. Set `theme_color_scheme` in a terminal session or in your fish startup files to one of the following options to change the prompt colors. diff --git a/fish_prompt.fish b/fish_prompt.fish index 455b44e..0d4ccf1 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -59,25 +59,25 @@ end function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' set -l ref (command git symbolic-ref HEAD ^/dev/null); and begin [ "$theme_display_git_master_branch" != 'yes' -a "$ref" = 'refs/heads/master' ] - and echo $__bobthefish_branch_glyph + and echo $branch_glyph and return - string replace 'refs/heads/' "$__bobthefish_branch_glyph " $ref + string replace 'refs/heads/' "$branch_glyph " $ref and return end set -l tag (command git describe --tags --exact-match ^/dev/null) - and echo "$__bobthefish_tag_glyph $tag" + and echo "$tag_glyph $tag" and return set -l branch (command git show-ref --head -s --abbrev | head -n1 ^/dev/null) - echo "$__bobthefish_detached_glyph $branch" + echo "$detached_glyph $branch" end function __bobthefish_hg_branch -S -d 'Get the current hg branch' set -l branch (command hg branch ^/dev/null) set -l book (command hg book | command grep \* | cut -d\ -f3) - echo "$__bobthefish_branch_glyph $branch @ $book" + echo "$branch_glyph $branch @ $book" end function __bobthefish_pretty_parent -S -a current_dir -d 'Print a parent directory, shortened to fit the prompt' @@ -212,7 +212,7 @@ function __bobthefish_git_ahead -S -d 'Print the ahead/behind state for the curr set ahead 1 case '<*' if [ $ahead -eq 1 ] - echo "$__bobthefish_git_plus_minus_glyph" + echo "$git_plus_minus_glyph" return end set behind 1 @@ -220,9 +220,9 @@ function __bobthefish_git_ahead -S -d 'Print the ahead/behind state for the curr end if [ $ahead -eq 1 ] - echo "$__bobthefish_git_plus_glyph" + echo "$git_plus_glyph" else if [ $behind -eq 1 ] - echo "$__bobthefish_git_minus_glyph" + echo "$git_minus_glyph" end end @@ -238,11 +238,11 @@ function __bobthefish_git_ahead_verbose -S -d 'Print a more verbose ahead/behind case '0 0' # equal to upstream return case '* 0' # ahead of upstream - echo "$__bobthefish_git_ahead_glyph$ahead" + echo "$git_ahead_glyph$ahead" case '0 *' # behind upstream - echo "$__bobthefish_git_behind_glyph$behind" + echo "$git_behind_glyph$behind" case '*' # diverged from upstream - echo "$__bobthefish_git_ahead_glyph$ahead$__bobthefish_git_behind_glyph$behind" + echo "$git_ahead_glyph$ahead$git_behind_glyph$behind" end end @@ -253,6 +253,7 @@ function __bobthefish_git_dirty_verbose -S -d 'Print a more verbose dirty state echo "$changes " | string replace -r '(\+0/(-0)?|/-0)' '' end + # ============================== # Segment functions # ============================== @@ -272,11 +273,11 @@ function __bobthefish_start_segment -S -d 'Start a prompt segment' echo -n ' ' case "$bg" # If the background is already the same color, draw a separator - echo -ns $__bobthefish_right_arrow_glyph ' ' + echo -ns $right_arrow_glyph ' ' case '*' # otherwise, draw the end of the previous segment and the start of the next set_color $__bobthefish_current_bg - echo -ns $__bobthefish_right_black_arrow_glyph ' ' + echo -ns $right_black_arrow_glyph ' ' set_color $fg $argv end @@ -284,12 +285,12 @@ function __bobthefish_start_segment -S -d 'Start a prompt segment' end function __bobthefish_path_segment -S -a current_dir -d 'Display a shortened form of a directory' - set -l segment_color $__color_path - set -l segment_basename_color $__color_path_basename + set -l segment_color $color_path + set -l segment_basename_color $color_path_basename if not [ -w "$current_dir" ] - set segment_color $__color_path_nowrite - set segment_basename_color $__color_path_nowrite_basename + set segment_color $color_path_nowrite + set segment_basename_color $color_path_nowrite_basename end __bobthefish_start_segment $segment_color @@ -316,7 +317,7 @@ function __bobthefish_finish_segments -S -d 'Close open prompt segments' if [ -n "$__bobthefish_current_bg" ] set_color normal set_color $__bobthefish_current_bg - echo -ns $__bobthefish_right_black_arrow_glyph ' ' + echo -ns $right_black_arrow_glyph ' ' end if [ "$theme_newline_cursor" = 'yes' ] @@ -325,7 +326,7 @@ function __bobthefish_finish_segments -S -d 'Close open prompt segments' if [ "$theme_powerline_fonts" = "no" ] echo -ns '> ' else - echo -ns "$__bobthefish_right_arrow_glyph " + echo -ns "$right_arrow_glyph " end else if [ "$theme_newline_cursor" = 'clean' ] echo -ens "\n" @@ -364,32 +365,32 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a no and set bg_jobs 1 if [ "$nonzero" -o "$superuser" -o "$bg_jobs" ] - __bobthefish_start_segment $__color_initial_segment_exit + __bobthefish_start_segment $color_initial_segment_exit if [ "$nonzero" ] set_color normal - set_color -b $__color_initial_segment_exit + set_color -b $color_initial_segment_exit if [ "$theme_show_exit_status" = 'yes' ] echo -ns $last_status ' ' else - echo -n $__bobthefish_nonzero_exit_glyph + echo -n $nonzero_exit_glyph end end if [ "$superuser" ] set_color normal if [ -z "$FAKEROOTKEY" ] - set_color -b $__color_initial_segment_su + set_color -b $color_initial_segment_su else - set_color -b $__color_initial_segment_exit + set_color -b $color_initial_segment_exit end - echo -n $__bobthefish_superuser_glyph + echo -n $superuser_glyph end if [ "$bg_jobs" ] set_color normal - set_color -b $__color_initial_segment_jobs - echo -n $__bobthefish_bg_job_glyph + set_color -b $color_initial_segment_jobs + echo -n $bg_job_glyph end end end @@ -402,16 +403,16 @@ function __bobthefish_prompt_vi -S -d 'Display vi mode' -o "$theme_display_vi" = 'yes' ]; or return switch $fish_bind_mode case default - __bobthefish_start_segment $__color_vi_mode_default + __bobthefish_start_segment $color_vi_mode_default echo -n 'N ' case insert - __bobthefish_start_segment $__color_vi_mode_insert + __bobthefish_start_segment $color_vi_mode_insert echo -n 'I ' case replace_one replace-one - __bobthefish_start_segment $__color_vi_mode_insert + __bobthefish_start_segment $color_vi_mode_insert echo -n 'R ' case visual - __bobthefish_start_segment $__color_vi_mode_visual + __bobthefish_start_segment $color_vi_mode_visual echo -n 'V ' end end @@ -446,34 +447,34 @@ function __bobthefish_prompt_vagrant_vbox -S -a id -d 'Display VirtualBox Vagran set -l vm_status (VBoxManage showvminfo --machinereadable $id ^/dev/null | command grep 'VMState=' | tr -d '"' | cut -d '=' -f 2) switch "$vm_status" case 'running' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_running_glyph" + set vagrant_status "$vagrant_status$vagrant_running_glyph" case 'poweroff' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_poweroff_glyph" + set vagrant_status "$vagrant_status$vagrant_poweroff_glyph" case 'aborted' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_aborted_glyph" + set vagrant_status "$vagrant_status$vagrant_aborted_glyph" case 'saved' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_saved_glyph" + set vagrant_status "$vagrant_status$vagrant_saved_glyph" case 'stopping' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_stopping_glyph" + set vagrant_status "$vagrant_status$vagrant_stopping_glyph" case '' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_unknown_glyph" + set vagrant_status "$vagrant_status$vagrant_unknown_glyph" end [ -z "$vagrant_status" ]; and return - __bobthefish_start_segment $__color_vagrant + __bobthefish_start_segment $color_vagrant echo -ns $vagrant_status ' ' end function __bobthefish_prompt_vagrant_vmware -S -a id -d 'Display VMWare Vagrant status' set -l vagrant_status if [ (pgrep -f "$id") ] - set vagrant_status "$vagrant_status$__bobthefish_vagrant_running_glyph" + set vagrant_status "$vagrant_status$vagrant_running_glyph" else - set vagrant_status "$vagrant_status$__bobthefish_vagrant_poweroff_glyph" + set vagrant_status "$vagrant_status$vagrant_poweroff_glyph" end [ -z "$vagrant_status" ]; and return - __bobthefish_start_segment $__color_vagrant + __bobthefish_start_segment $color_vagrant echo -ns $vagrant_status ' ' end @@ -482,27 +483,27 @@ function __bobthefish_prompt_vagrant_parallels -S -d 'Display Parallels Vagrant set -l vm_status (prlctl list $id -o status ^/dev/null | command tail -1) switch "$vm_status" case 'running' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_running_glyph" + set vagrant_status "$vagrant_status$vagrant_running_glyph" case 'stopped' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_poweroff_glyph" + set vagrant_status "$vagrant_status$vagrant_poweroff_glyph" case 'paused' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_saved_glyph" + set vagrant_status "$vagrant_status$vagrant_saved_glyph" case 'suspended' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_saved_glyph" + set vagrant_status "$vagrant_status$vagrant_saved_glyph" case 'stopping' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_stopping_glyph" + set vagrant_status "$vagrant_status$vagrant_stopping_glyph" case '' - set vagrant_status "$vagrant_status$__bobthefish_vagrant_unknown_glyph" + set vagrant_status "$vagrant_status$vagrant_unknown_glyph" end [ -z "$vagrant_status" ]; and return - __bobthefish_start_segment $__color_vagrant + __bobthefish_start_segment $color_vagrant echo -ns $vagrant_status ' ' end function __bobthefish_prompt_docker -S -d 'Display Docker machine name' [ "$theme_display_docker_machine" = 'no' -o -z "$DOCKER_MACHINE_NAME" ]; and return - __bobthefish_start_segment $__color_vagrant + __bobthefish_start_segment $color_vagrant echo -ns $DOCKER_MACHINE_NAME ' ' end @@ -521,7 +522,7 @@ function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context' set -l context (string trim -c '"\' ' -- $val) [ -z "$context" ]; and return - __bobthefish_start_segment $__color_k8s + __bobthefish_start_segment $color_k8s echo -ns $context ' ' return end @@ -541,7 +542,7 @@ function __bobthefish_prompt_user -S -d 'Display current user and hostname' and set -l display_hostname if set -q display_user - __bobthefish_start_segment $__color_username + __bobthefish_start_segment $color_username echo -ns (whoami) end @@ -552,10 +553,10 @@ function __bobthefish_prompt_user -S -d 'Display current user and hostname' # reset colors without starting a new segment... # (so we can have a bold username and non-bold hostname) set_color normal - set_color -b $__color_hostname[1] $__color_hostname[2..-1] + set_color -b $color_hostname[1] $color_hostname[2..-1] echo -ns '@' $hostname else - __bobthefish_start_segment $__color_hostname + __bobthefish_start_segment $color_hostname echo -ns $hostname end end @@ -655,20 +656,20 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' set ruby_version $asdf_ruby_version end [ -z "$ruby_version" ]; and return - __bobthefish_start_segment $__color_rvm - echo -ns $__bobthefish_ruby_glyph $ruby_version ' ' + __bobthefish_start_segment $color_rvm + echo -ns $ruby_glyph $ruby_version ' ' end function __bobthefish_virtualenv_python_version -S -d 'Get current Python version' switch (python --version ^&1 | tr '\n' ' ') case 'Python 2*PyPy*' - echo $__bobthefish_pypy_glyph + echo $pypy_glyph case 'Python 3*PyPy*' - echo -s $__bobthefish_pypy_glyph $__bobthefish_superscript_glyph[3] + echo -s $pypy_glyph $superscript_glyph[3] case 'Python 2*' - echo $__bobthefish_superscript_glyph[2] + echo $superscript_glyph[2] case 'Python 3*' - echo $__bobthefish_superscript_glyph[3] + echo $superscript_glyph[3] end end @@ -676,17 +677,16 @@ function __bobthefish_prompt_virtualfish -S -d "Display current Python virtual e [ "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV" ]; and return set -l version_glyph (__bobthefish_virtualenv_python_version) if [ "$version_glyph" ] - __bobthefish_start_segment $__color_virtualfish - echo -ns $__bobthefish_virtualenv_glyph $version_glyph ' ' + __bobthefish_start_segment $color_virtualfish + echo -ns $virtualenv_glyph $version_glyph ' ' end echo -ns (basename "$VIRTUAL_ENV") ' ' end function __bobthefish_prompt_virtualgo -S -d 'Display current Go virtual environment' [ "$theme_display_virtualgo" = 'no' -o -z "$VIRTUALGO" ]; and return - __bobthefish_start_segment $__color_virtualgo - echo -ns $__bobthefish_go_glyph - echo -ns (basename "$VIRTUALGO") ' ' + __bobthefish_start_segment $color_virtualgo + echo -ns $go_glyph ' ' (basename "$VIRTUALGO") ' ' set_color normal end @@ -709,15 +709,15 @@ function __bobthefish_prompt_hg -S -a current_dir -d 'Display the actual hg stat [ "$flags" ] and set flags "" - set -l flag_colors $__color_repo + set -l flag_colors $color_repo if [ "$dirty" ] - set flag_colors $__color_repo_dirty + set flag_colors $color_repo_dirty end __bobthefish_path_segment $current_dir __bobthefish_start_segment $flag_colors - echo -ns $__bobthefish_hg_glyph ' ' + echo -ns $hg_glyph ' ' __bobthefish_start_segment $flag_colors echo -ns (__bobthefish_hg_branch) $flags ' ' @@ -726,9 +726,9 @@ function __bobthefish_prompt_hg -S -a current_dir -d 'Display the actual hg stat set -l project_pwd (__bobthefish_project_pwd $current_dir) if [ "$project_pwd" ] if [ -w "$PWD" ] - __bobthefish_start_segment $__color_path + __bobthefish_start_segment $color_path else - __bobthefish_start_segment $__color_path_nowrite + __bobthefish_start_segment $color_path_nowrite end echo -ns $project_pwd ' ' @@ -740,15 +740,15 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st if [ "$theme_display_git_dirty" != 'no' ] set -l show_dirty (command git config --bool bash.showDirtyState ^/dev/null) if [ "$show_dirty" != 'false' ] - set dirty (command git diff --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$__bobthefish_git_dirty_glyph") + set dirty (command git diff --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$git_dirty_glyph") if [ "$dirty" -a "$theme_display_git_dirty_verbose" = 'yes' ] set dirty "$dirty"(__bobthefish_git_dirty_verbose) end end end - set -l staged (command git diff --cached --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$__bobthefish_git_staged_glyph") - set -l stashed (command git rev-parse --verify --quiet refs/stash >/dev/null; and echo -n "$__bobthefish_git_stashed_glyph") + set -l staged (command git diff --cached --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$git_staged_glyph") + set -l stashed (command git rev-parse --verify --quiet refs/stash >/dev/null; and echo -n "$git_stashed_glyph") set -l ahead (__bobthefish_git_ahead) set -l new '' @@ -757,7 +757,7 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st if [ "$show_untracked" != 'false' ] set new (command git ls-files --other --exclude-standard --directory --no-empty-directory ^/dev/null) if [ "$new" ] - set new "$__bobthefish_git_untracked_glyph" + set new "$git_untracked_glyph" end end end @@ -766,11 +766,11 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st [ "$flags" ] and set flags " $flags" - set -l flag_colors $__color_repo + set -l flag_colors $color_repo if [ "$dirty" ] - set flag_colors $__color_repo_dirty + set flag_colors $color_repo_dirty else if [ "$staged" ] - set flag_colors $__color_repo_staged + set flag_colors $color_repo_staged end __bobthefish_path_segment $current_dir @@ -783,9 +783,9 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st set -l project_pwd (__bobthefish_project_pwd $current_dir) if [ "$project_pwd" ] if [ -w "$PWD" ] - __bobthefish_start_segment $__color_path + __bobthefish_start_segment $color_path else - __bobthefish_start_segment $__color_path_nowrite + __bobthefish_start_segment $color_path_nowrite end echo -ns $project_pwd ' ' @@ -808,9 +808,9 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st end if [ "$project_pwd" -o "$work_dir" ] - set -l colors $__color_path + set -l colors $color_path if not [ -w "$PWD" ] - set colors $__color_path_nowrite + set colors $color_path_nowrite end __bobthefish_start_segment $colors @@ -822,7 +822,7 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st echo -n "$work_parent/" end set_color normal - set_color -b $__color_repo_work_tree + set_color -b $color_repo_work_tree echo -n (__bobthefish_basename $work_dir) set_color normal set_color -b $colors @@ -838,9 +838,9 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st set project_pwd (string trim --left --chars=/ -- $project_pwd) if [ "$project_pwd" ] - set -l colors $__color_path + set -l colors $color_path if not [ -w "$PWD" ] - set colors $__color_path_nowrite + set colors $color_path_nowrite end __bobthefish_start_segment $colors @@ -855,118 +855,6 @@ function __bobthefish_prompt_dir -S -d 'Display a shortened form of the current end -# ============================== -# Debugging functions -# ============================== - -function __bobthefish_display_colors -d 'Print example prompts using the current color scheme' - set -g __bobthefish_display_colors -end - -function __bobthefish_maybe_display_colors -S - set -q __bobthefish_display_colors; or return - set -e __bobthefish_display_colors - - echo - set_color normal - - __bobthefish_start_segment $__color_initial_segment_exit - echo -n exit '! ' - set_color -b $__color_initial_segment_su - echo -n su '$ ' - set_color -b $__color_initial_segment_jobs - echo -n jobs '% ' - __bobthefish_finish_segments - set_color normal - echo -n "(<- initial_segment)" - echo - - __bobthefish_start_segment $__color_path - echo -n /color/path/ - set_color -b $__color_path_basename - echo -ns basename ' ' - __bobthefish_finish_segments - echo - - __bobthefish_start_segment $__color_path_nowrite - echo -n /color/path/nowrite/ - set_color -b $__color_path_nowrite_basename - echo -ns basename ' ' - __bobthefish_finish_segments - echo - - __bobthefish_start_segment $__color_path - echo -n /color/path/ - set_color -b $__color_path_basename - echo -ns basename ' ' - __bobthefish_start_segment $__color_repo - echo -n "$__bobthefish_branch_glyph repo $__bobthefish_git_stashed_glyph " - __bobthefish_finish_segments - echo - - __bobthefish_start_segment $__color_path - echo -n /color/path/ - set_color -b $__color_path_basename - echo -ns basename ' ' - __bobthefish_start_segment $__color_repo_dirty - echo -n "$__bobthefish_tag_glyph repo_dirty $__bobthefish_git_dirty_glyph " - __bobthefish_finish_segments - echo - - __bobthefish_start_segment $__color_path - echo -n /color/path/ - set_color -b $__color_path_basename - echo -ns basename ' ' - __bobthefish_start_segment $__color_repo_staged - echo -n "$__bobthefish_detached_glyph repo_staged $__bobthefish_git_staged_glyph " - __bobthefish_finish_segments - echo - - __bobthefish_start_segment $__color_vi_mode_default - echo -ns vi_mode_default ' ' - __bobthefish_finish_segments - __bobthefish_start_segment $__color_vi_mode_insert - echo -ns vi_mode_insert ' ' - __bobthefish_finish_segments - __bobthefish_start_segment $__color_vi_mode_visual - echo -ns vi_mode_visual ' ' - __bobthefish_finish_segments - echo - - __bobthefish_start_segment $__color_vagrant - echo -ns $__bobthefish_vagrant_running_glyph ' ' vagrant ' ' - __bobthefish_finish_segments - echo - - __bobthefish_start_segment $__color_username - echo -n username - set_color normal - set_color -b $__color_hostname[1] $__color_hostname[2..-1] - echo -ns @hostname ' ' - __bobthefish_finish_segments - echo - - __bobthefish_start_segment $__color_rvm - echo -ns $__bobthefish_ruby_glyph rvm ' ' - __bobthefish_finish_segments - - __bobthefish_start_segment $__color_virtualfish - echo -ns $__bobthefish_virtualenv_glyph virtualfish ' ' - __bobthefish_finish_segments - - __bobthefish_start_segment $__color_virtualgo - echo -ns $__bobthefish_go_glyph virtualgo ' ' - __bobthefish_finish_segments - - __bobthefish_start_segment $__color_desk - echo -ns $__bobthefish_desk_glyph desk ' ' - __bobthefish_finish_segments - - echo -e "\n" - -end - - # ============================== # Apply theme # ============================== @@ -975,610 +863,14 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' # Save the last status for later (do this before the `set` calls below) set -l last_status $status - # Powerline glyphs - set -l __bobthefish_branch_glyph \uE0A0 - set -l __bobthefish_right_black_arrow_glyph \uE0B0 - set -l __bobthefish_right_arrow_glyph \uE0B1 - set -l __bobthefish_left_black_arrow_glyph \uE0B2 - set -l __bobthefish_left_arrow_glyph \uE0B3 - - # Additional glyphs - set -l __bobthefish_detached_glyph \u27A6 - set -l __bobthefish_tag_glyph \u2302 - set -l __bobthefish_nonzero_exit_glyph '! ' - set -l __bobthefish_superuser_glyph '$ ' - set -l __bobthefish_bg_job_glyph '% ' - set -l __bobthefish_hg_glyph \u263F - - # Python glyphs - set -l __bobthefish_superscript_glyph \u00B9 \u00B2 \u00B3 - set -l __bobthefish_virtualenv_glyph \u25F0 - set -l __bobthefish_pypy_glyph \u1D56 - - set -l __bobthefish_ruby_glyph '' - set -l __bobthefish_go_glyph '' - - # Desk glyphs - set -l __bobthefish_desk_glyph \u25F2 - - # Vagrant glyphs - set -l __bobthefish_vagrant_running_glyph \u2191 # ↑ 'running' - set -l __bobthefish_vagrant_poweroff_glyph \u2193 # ↓ 'poweroff' - set -l __bobthefish_vagrant_aborted_glyph \u2715 # ✕ 'aborted' - set -l __bobthefish_vagrant_saved_glyph \u21E1 # ⇡ 'saved' - set -l __bobthefish_vagrant_stopping_glyph \u21E3 # ⇣ 'stopping' - set -l __bobthefish_vagrant_unknown_glyph '!' # strange cases - - # Git glyphs - set -l __bobthefish_git_dirty_glyph '*' - set -l __bobthefish_git_staged_glyph '~' - set -l __bobthefish_git_stashed_glyph '$' - set -l __bobthefish_git_untracked_glyph '…' - set -l __bobthefish_git_ahead_glyph \u2191 # '↑' - set -l __bobthefish_git_behind_glyph \u2193 # '↓' - set -l __bobthefish_git_plus_glyph '+' - set -l __bobthefish_git_minus_glyph '-' - set -l __bobthefish_git_plus_minus_glyph '±' - - # Disable Powerline fonts - if [ "$theme_powerline_fonts" = "no" ] - set __bobthefish_branch_glyph \u2387 - set __bobthefish_right_black_arrow_glyph '' - set __bobthefish_right_arrow_glyph '' - set __bobthefish_left_black_arrow_glyph '' - set __bobthefish_left_arrow_glyph '' - end - - # Use prettier Nerd Fonts glyphs - if [ "$theme_nerd_fonts" = "yes" ] - set __bobthefish_branch_glyph \uF418 - set __bobthefish_detached_glyph \uF417 - set __bobthefish_tag_glyph \uF412 - - set __bobthefish_virtualenv_glyph \uE73C ' ' - set __bobthefish_ruby_glyph \uE791 ' ' - set __bobthefish_go_glyph \uE626 ' ' - - set __bobthefish_vagrant_running_glyph \uF431 # ↑ 'running' - set __bobthefish_vagrant_poweroff_glyph \uF433 # ↓ 'poweroff' - set __bobthefish_vagrant_aborted_glyph \uF468 # ✕ 'aborted' - set __bobthefish_vagrant_unknown_glyph \uF421 # strange cases - - set __bobthefish_git_dirty_glyph \uF448 '' # nf-oct-pencil - set __bobthefish_git_staged_glyph \uF0C7 '' # nf-fa-save - set __bobthefish_git_stashed_glyph \uF0C6 '' # nf-fa-paperclip - set __bobthefish_git_untracked_glyph \uF128 '' # nf-fa-question - # set __bobthefish_git_untracked_glyph \uF141 '' # nf-fa-ellipsis_h - - set __bobthefish_git_ahead_glyph \uF47B # nf-oct-chevron_up - set __bobthefish_git_behind_glyph \uF47C # nf-oct-chevron_down - - set __bobthefish_git_plus_glyph \uF0DE # fa-sort-asc - set __bobthefish_git_minus_glyph \uF0DD # fa-sort-desc - set __bobthefish_git_plus_minus_glyph \uF0DC # fa-sort - end - - # Avoid ambiguous glyphs - if [ "$theme_avoid_ambiguous_glyphs" = "yes" ] - set __bobthefish_git_untracked_glyph '...' - end - - - # Colors - - switch "$theme_color_scheme" - case 'user' - # Do not set any variables in this section. - - # If you want to create your own color scheme, set `theme_color_scheme` to - # `user` and define the `__color_*` variables listed below in your fish - # startup file (`$OMF_CONFIG/init.fish`, or similar). - - # The value for each variable is an argument to pass to `set_color -b`. - # You can copy the commented code below as a base for your custom colors. - # Use `__bobthefish_display_colors` at the command line to easily see what - # these variables are used for. - - # See the built-in color schemes below for more examples. - - # # Example bobthefish color scheme: - # set -g theme_color_scheme user - # - # set -g __color_initial_segment_exit ffffff ce000f --bold - # set -g __color_initial_segment_su ffffff 189303 --bold - # set -g __color_initial_segment_jobs ffffff 255e87 --bold - # - # set -g __color_path 333333 999999 - # set -g __color_path_basename 333333 ffffff --bold - # set -g __color_path_nowrite 660000 cc9999 - # set -g __color_path_nowrite_basename 660000 cc9999 --bold - # - # set -g __color_repo addc10 0c4801 - # set -g __color_repo_work_tree 333333 ffffff --bold - # set -g __color_repo_dirty ce000f ffffff - # set -g __color_repo_staged f6b117 3a2a03 - # - # set -g __color_vi_mode_default 999999 333333 --bold - # set -g __color_vi_mode_insert 189303 333333 --bold - # set -g __color_vi_mode_visual f6b117 3a2a03 --bold - # - # set -g __color_vagrant 48b4fb ffffff --bold - # set -g __color_username cccccc 255e87 --bold - # set -g __color_hostname cccccc 255e87 - # set -g __color_rvm af0000 cccccc --bold - # set -g __color_virtualfish 005faf cccccc --bold - # set -g __color_virtualgo 005faf cccccc --bold - # set -g __color_desk 005faf cccccc --bold - - case 'terminal' 'terminal-dark*' - set -l colorfg black - [ $theme_color_scheme = 'terminal-dark-white' ]; and set colorfg white - set __color_initial_segment_exit white red --bold - set __color_initial_segment_su white green --bold - set __color_initial_segment_jobs white blue --bold - - set __color_path black white - set __color_path_basename black white --bold - set __color_path_nowrite magenta $colorfg - set __color_path_nowrite_basename magenta $colorfg --bold - - set __color_repo green $colorfg - set __color_repo_work_tree black $colorfg --bold - set __color_repo_dirty brred $colorfg - set __color_repo_staged yellow $colorfg - - set __color_vi_mode_default brblue $colorfg --bold - set __color_vi_mode_insert brgreen $colorfg --bold - set __color_vi_mode_visual bryellow $colorfg --bold - - set __color_vagrant brcyan $colorfg - set __color_k8s magenta white --bold - set __color_username white black --bold - set __color_hostname white black - set __color_rvm brmagenta $colorfg --bold - set __color_virtualfish brblue $colorfg --bold - set __color_virtualgo brblue $colorfg --bold - set __color_desk brblue $colorfg --bold - - case 'terminal-light*' - set -l colorfg white - [ $theme_color_scheme = 'terminal-light-black' ]; and set colorfg black - set __color_initial_segment_exit black red --bold - set __color_initial_segment_su black green --bold - set __color_initial_segment_jobs black blue --bold - - set __color_path white black - set __color_path_basename white black --bold - set __color_path_nowrite magenta $colorfg - set __color_path_nowrite_basename magenta $colorfg --bold - - set __color_repo green $colorfg - set __color_repo_work_tree white $colorfg --bold - set __color_repo_dirty brred $colorfg - set __color_repo_staged yellow $colorfg - - set __color_vi_mode_default brblue $colorfg --bold - set __color_vi_mode_insert brgreen $colorfg --bold - set __color_vi_mode_visual bryellow $colorfg --bold - - set __color_vagrant brcyan $colorfg - set __color_k8s magenta white --bold - set __color_username black white --bold - set __color_hostname black white - set __color_rvm brmagenta $colorfg --bold - set __color_virtualfish brblue $colorfg --bold - set __color_virtualgo brblue $colorfg --bold - set __color_desk brblue $colorfg --bold - - case 'terminal2' 'terminal2-dark*' - set -l colorfg black - [ $theme_color_scheme = 'terminal2-dark-white' ]; and set colorfg white - set __color_initial_segment_exit grey red --bold - set __color_initial_segment_su grey green --bold - set __color_initial_segment_jobs grey blue --bold - - set __color_path brgrey white - set __color_path_basename brgrey white --bold - set __color_path_nowrite magenta $colorfg - set __color_path_nowrite_basename magenta $colorfg --bold - - set __color_repo green $colorfg - set __color_repo_work_tree brgrey $colorfg --bold - set __color_repo_dirty brred $colorfg - set __color_repo_staged yellow $colorfg - - set __color_vi_mode_default brblue $colorfg --bold - set __color_vi_mode_insert brgreen $colorfg --bold - set __color_vi_mode_visual bryellow $colorfg --bold - - set __color_vagrant brcyan $colorfg - set __color_k8s magenta white --bold - set __color_username brgrey white --bold - set __color_hostname brgrey white - set __color_rvm brmagenta $colorfg --bold - set __color_virtualfish brblue $colorfg --bold - set __color_virtualgo brblue $colorfg --bold - set __color_desk brblue $colorfg --bold - - case 'terminal2-light*' - set -l colorfg white - [ $theme_color_scheme = 'terminal2-light-black' ]; and set colorfg black - set __color_initial_segment_exit brgrey red --bold - set __color_initial_segment_su brgrey green --bold - set __color_initial_segment_jobs brgrey blue --bold - - set __color_path grey black - set __color_path_basename grey black --bold - set __color_path_nowrite magenta $colorfg - set __color_path_nowrite_basename magenta $colorfg --bold - - set __color_repo green $colorfg - set __color_repo_work_tree grey $colorfg --bold - set __color_repo_dirty brred $colorfg - set __color_repo_staged yellow $colorfg - - set __color_vi_mode_default brblue $colorfg --bold - set __color_vi_mode_insert brgreen $colorfg --bold - set __color_vi_mode_visual bryellow $colorfg --bold - - set __color_vagrant brcyan $colorfg - set __color_k8s magenta white --bold - set __color_username grey black --bold - set __color_hostname grey black - set __color_rvm brmagenta $colorfg --bold - set __color_virtualfish brblue $colorfg --bold - set __color_virtualgo brblue $colorfg --bold - set __color_desk brblue $colorfg --bold - - case 'zenburn' - set -l grey 333333 # a bit darker than normal zenburn grey - set -l red CC9393 - set -l green 7F9F7F - set -l yellow E3CEAB - set -l orange DFAF8F - set -l blue 8CD0D3 - set -l white DCDCCC - - set __color_initial_segment_exit $white $red --bold - set __color_initial_segment_su $white $green --bold - set __color_initial_segment_jobs $white $blue --bold - - set __color_path $grey $white - set __color_path_basename $grey $white --bold - set __color_path_nowrite $grey $red - set __color_path_nowrite_basename $grey $red --bold - - set __color_repo $green $grey - set __color_repo_work_tree $grey $grey --bold - set __color_repo_dirty $red $grey - set __color_repo_staged $yellow $grey - - set __color_vi_mode_default $grey $yellow --bold - set __color_vi_mode_insert $green $white --bold - set __color_vi_mode_visual $yellow $grey --bold - - set __color_vagrant $blue $green --bold - set __color_k8s $green $white --bold - set __color_username $grey $blue --bold - set __color_hostname $grey $blue - set __color_rvm $red $grey --bold - set __color_virtualfish $blue $grey --bold - set __color_virtualgo $blue $grey --bold - set __color_desk $blue $grey --bold - - case 'base16-light' - set -l base00 181818 - set -l base01 282828 - set -l base02 383838 - set -l base03 585858 - set -l base04 b8b8b8 - set -l base05 d8d8d8 - set -l base06 e8e8e8 - set -l base07 f8f8f8 - set -l base08 ab4642 # red - set -l base09 dc9656 # orange - set -l base0A f7ca88 # yellow - set -l base0B a1b56c # green - set -l base0C 86c1b9 # cyan - set -l base0D 7cafc2 # blue - set -l base0E ba8baf # violet - set -l base0F a16946 # brown - - set -l colorfg $base00 - - set __color_initial_segment_exit $base02 $base08 --bold - set __color_initial_segment_su $base02 $base0B --bold - set __color_initial_segment_jobs $base02 $base0D --bold - - set __color_path $base06 $base02 - set __color_path_basename $base06 $base01 --bold - set __color_path_nowrite $base06 $base08 - set __color_path_nowrite_basename $base06 $base08 --bold - - set __color_repo $base0B $colorfg - set __color_repo_work_tree $base06 $colorfg --bold - set __color_repo_dirty $base08 $colorfg - set __color_repo_staged $base09 $colorfg - - set __color_vi_mode_default $base04 $colorfg --bold - set __color_vi_mode_insert $base0B $colorfg --bold - set __color_vi_mode_visual $base09 $colorfg --bold - - set __color_vagrant $base0C $colorfg --bold - set __color_k8s $base06 $colorfg --bold - set __color_username $base02 $base0D --bold - set __color_hostname $base02 $base0D - set __color_rvm $base08 $colorfg --bold - set __color_virtualfish $base0D $colorfg --bold - set __color_virtualgo $base0D $colorfg --bold - - case 'base16' 'base16-dark' - set -l base00 181818 - set -l base01 282828 - set -l base02 383838 - set -l base03 585858 - set -l base04 b8b8b8 - set -l base05 d8d8d8 - set -l base06 e8e8e8 - set -l base07 f8f8f8 - set -l base08 ab4642 # red - set -l base09 dc9656 # orange - set -l base0A f7ca88 # yellow - set -l base0B a1b56c # green - set -l base0C 86c1b9 # cyan - set -l base0D 7cafc2 # blue - set -l base0E ba8baf # violet - set -l base0F a16946 # brown - - set -l colorfg $base07 - - set __color_initial_segment_exit $base05 $base08 --bold - set __color_initial_segment_su $base05 $base0B --bold - set __color_initial_segment_jobs $base05 $base0D --bold - - set __color_path $base02 $base05 - set __color_path_basename $base02 $base06 --bold - set __color_path_nowrite $base02 $base08 - set __color_path_nowrite_basename $base02 $base08 --bold - - set __color_repo $base0B $colorfg - set __color_repo_work_tree $base02 $colorfg --bold - set __color_repo_dirty $base08 $colorfg - set __color_repo_staged $base09 $colorfg - - set __color_vi_mode_default $base03 $colorfg --bold - set __color_vi_mode_insert $base0B $colorfg --bold - set __color_vi_mode_visual $base09 $colorfg --bold - - set __color_vagrant $base0C $colorfg --bold - set __color_k8s $base0B $colorfg --bold - set __color_username $base02 $base0D --bold - set __color_hostname $base02 $base0D - set __color_rvm $base08 $colorfg --bold - set __color_virtualfish $base0D $colorfg --bold - set __color_virtualgo $base0D $colorfg --bold - set __color_desk $base0D $colorfg --bold - - case 'solarized-light' - set -l base03 002b36 - set -l base02 073642 - set -l base01 586e75 - set -l base00 657b83 - set -l base0 839496 - set -l base1 93a1a1 - set -l base2 eee8d5 - set -l base3 fdf6e3 - set -l yellow b58900 - set -l orange cb4b16 - set -l red dc322f - set -l magenta d33682 - set -l violet 6c71c4 - set -l blue 268bd2 - set -l cyan 2aa198 - set -l green 859900 - - set colorfg $base03 - - set __color_initial_segment_exit $base02 $red --bold - set __color_initial_segment_su $base02 $green --bold - set __color_initial_segment_jobs $base02 $blue --bold - - set __color_path $base2 $base00 - set __color_path_basename $base2 $base01 --bold - set __color_path_nowrite $base2 $orange - set __color_path_nowrite_basename $base2 $orange --bold - - set __color_repo $green $colorfg - set __color_repo_work_tree $base2 $colorfg --bold - set __color_repo_dirty $red $colorfg - set __color_repo_staged $yellow $colorfg - - set __color_vi_mode_default $blue $colorfg --bold - set __color_vi_mode_insert $green $colorfg --bold - set __color_vi_mode_visual $yellow $colorfg --bold - - set __color_vagrant $violet $colorfg --bold - set __color_k8s $green $colorfg --bold - set __color_username $base2 $blue --bold - set __color_hostname $base2 $blue - set __color_rvm $red $colorfg --bold - set __color_virtualfish $cyan $colorfg --bold - set __color_virtualgo $cyan $colorfg --bold - set __color_desk $cyan $colorfg --bold - - case 'solarized' 'solarized-dark' - set -l base03 002b36 - set -l base02 073642 - set -l base01 586e75 - set -l base00 657b83 - set -l base0 839496 - set -l base1 93a1a1 - set -l base2 eee8d5 - set -l base3 fdf6e3 - set -l yellow b58900 - set -l orange cb4b16 - set -l red dc322f - set -l magenta d33682 - set -l violet 6c71c4 - set -l blue 268bd2 - set -l cyan 2aa198 - set -l green 859900 - - set colorfg $base3 - - set __color_initial_segment_exit $base2 $red --bold - set __color_initial_segment_su $base2 $green --bold - set __color_initial_segment_jobs $base2 $blue --bold - - set __color_path $base02 $base0 - set __color_path_basename $base02 $base1 --bold - set __color_path_nowrite $base02 $orange - set __color_path_nowrite_basename $base02 $orange --bold - - set __color_repo $green $colorfg - set __color_repo_work_tree $base02 $colorfg --bold - set __color_repo_dirty $red $colorfg - set __color_repo_staged $yellow $colorfg - - set __color_vi_mode_default $blue $colorfg --bold - set __color_vi_mode_insert $green $colorfg --bold - set __color_vi_mode_visual $yellow $colorfg --bold - - set __color_vagrant $violet $colorfg --bold - set __color_k8s $green $colorfg --bold - set __color_username $base02 $blue --bold - set __color_hostname $base02 $blue - set __color_rvm $red $colorfg --bold - set __color_virtualfish $cyan $colorfg --bold - set __color_virtualgo $cyan $colorfg --bold - set __color_desk $cyan $colorfg --bold - - case 'light' - # light medium dark - # ------ ------ ------ - set -l red cc9999 ce000f 660000 - set -l green addc10 189303 0c4801 - set -l blue 48b4fb 005faf 255e87 - set -l orange f6b117 unused 3a2a03 - set -l brown bf5e00 803f00 4d2600 - set -l grey cccccc 999999 333333 - set -l white ffffff - set -l black 000000 - set -l ruby_red af0000 - - set __color_initial_segment_exit $grey[3] $red[2] --bold - set __color_initial_segment_su $grey[3] $green[2] --bold - set __color_initial_segment_jobs $grey[3] $blue[3] --bold - - set __color_path $grey[1] $grey[2] - set __color_path_basename $grey[1] $grey[3] --bold - set __color_path_nowrite $red[1] $red[3] - set __color_path_nowrite_basename $red[1] $red[3] --bold - - set __color_repo $green[1] $green[3] - set __color_repo_work_tree $grey[1] $white --bold - set __color_repo_dirty $red[2] $white - set __color_repo_staged $orange[1] $orange[3] - - set __color_vi_mode_default $grey[2] $grey[3] --bold - set __color_vi_mode_insert $green[2] $grey[3] --bold - set __color_vi_mode_visual $orange[1] $orange[3] --bold - - set __color_vagrant $blue[1] $white --bold - set __color_k8s $green[1] $colorfg --bold - set __color_username $grey[1] $blue[3] --bold - set __color_hostname $grey[1] $blue[3] - set __color_rvm $ruby_red $grey[1] --bold - set __color_virtualfish $blue[2] $grey[1] --bold - set __color_virtualgo $blue[2] $grey[1] --bold - set __color_desk $blue[2] $grey[1] --bold - - case 'gruvbox' - # light medium dark darkest - # ------ ------ ------ ------- - set -l red fb4934 cc241d - set -l green b8bb26 98971a - set -l yellow fabd2f d79921 - set -l aqua 8ec07c 689d6a - set -l blue 83a598 458588 - set -l grey cccccc 999999 333333 - set -l fg fbf1c7 ebdbb2 d5c4a1 a89984 - set -l bg 504945 282828 - - set __color_initial_segment_exit $fg[1] $red[2] --bold - set __color_initial_segment_su $fg[1] $green[2] --bold - set __color_initial_segment_jobs $fg[1] $aqua[2] --bold - - set __color_path $bg[1] $fg[2] - set __color_path_basename $bg[1] $fg[2] --bold - set __color_path_nowrite $red[1] $fg[2] - set __color_path_nowrite_basename $red[1] $fg[2] --bold - - set __color_repo $green[2] $bg[1] - set __color_repo_work_tree $bg[1] $fg[2] --bold - set __color_repo_dirty $red[2] $fg[2] - set __color_repo_staged $yellow[1] $bg[1] - - set __color_vi_mode_default $fg[4] $bg[2] --bold - set __color_vi_mode_insert $blue[1] $bg[2] --bold - set __color_vi_mode_visual $yellow[1] $bg[2] --bold - - set __color_vagrant $blue[2] $fg[2] --bold - set __color_k8s $green[2] $fg[2] --bold - set __color_username $fg[3] $blue[2] --bold - set __color_hostname $fg[3] $blue[2] - set __color_rvm $red[2] $fg[2] --bold - set __color_virtualfish $blue[2] $fg[2] --bold - set __color_virtualgo $blue[2] $fg[2] --bold - set __color_desk $blue[2] $fg[2] --bold - - case '*' # default dark theme - # light medium dark - # ------ ------ ------ - set -l red cc9999 ce000f 660000 - set -l green addc10 189303 0c4801 - set -l blue 48b4fb 005faf 255e87 - set -l orange f6b117 unused 3a2a03 - set -l brown bf5e00 803f00 4d2600 - set -l grey cccccc 999999 333333 - set -l white ffffff - set -l black 000000 - set -l ruby_red af0000 - - set __color_initial_segment_exit $white $red[2] --bold - set __color_initial_segment_su $white $green[2] --bold - set __color_initial_segment_jobs $white $blue[3] --bold - - set __color_path $grey[3] $grey[2] - set __color_path_basename $grey[3] $white --bold - set __color_path_nowrite $red[3] $red[1] - set __color_path_nowrite_basename $red[3] $red[1] --bold - - set __color_repo $green[1] $green[3] - set __color_repo_work_tree $grey[3] $white --bold - set __color_repo_dirty $red[2] $white - set __color_repo_staged $orange[1] $orange[3] - - set __color_vi_mode_default $grey[2] $grey[3] --bold - set __color_vi_mode_insert $green[2] $grey[3] --bold - set __color_vi_mode_visual $orange[1] $orange[3] --bold - - set __color_vagrant $blue[1] $white --bold - set __color_k8s $green[2] $white --bold - set __color_username $grey[1] $blue[3] --bold - set __color_hostname $grey[1] $blue[3] - set __color_rvm $ruby_red $grey[1] --bold - set __color_virtualfish $blue[2] $grey[1] --bold - set __color_virtualgo $blue[2] $grey[1] --bold - set __color_desk $blue[2] $grey[1] --bold - end + __bobthefish_glyphs + __bobthefish_colors $theme_color_scheme + type -q bobthefish_colors + and bobthefish_colors # Start each line with a blank slate set -l __bobthefish_current_bg - # Internal: used for testing color schemes - __bobthefish_maybe_display_colors - # Status flags and input mode __bobthefish_prompt_status $last_status __bobthefish_prompt_vi diff --git a/functions/__bobthefish_colors.fish b/functions/__bobthefish_colors.fish new file mode 100644 index 0000000..eead958 --- /dev/null +++ b/functions/__bobthefish_colors.fish @@ -0,0 +1,534 @@ +function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthefish' + switch "$color_scheme" + case 'user' + __bobthefish_user_color_scheme_deprecated + return + + case 'terminal' 'terminal-dark*' + set -l colorfg black + [ "$color_scheme" = 'terminal-dark-white' ]; and set colorfg white + set -x color_initial_segment_exit white red --bold + set -x color_initial_segment_su white green --bold + set -x color_initial_segment_jobs white blue --bold + + set -x color_path black white + set -x color_path_basename black white --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree black $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_username white black --bold + set -x color_hostname white black + set -x color_rvm brmagenta $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + + case 'terminal-light*' + set -l colorfg white + [ "$color_scheme" = 'terminal-light-black' ]; and set colorfg black + set -x color_initial_segment_exit black red --bold + set -x color_initial_segment_su black green --bold + set -x color_initial_segment_jobs black blue --bold + + set -x color_path white black + set -x color_path_basename white black --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree white $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_username black white --bold + set -x color_hostname black white + set -x color_rvm brmagenta $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + + case 'terminal2' 'terminal2-dark*' + set -l colorfg black + [ "$color_scheme" = 'terminal2-dark-white' ]; and set colorfg white + set -x color_initial_segment_exit grey red --bold + set -x color_initial_segment_su grey green --bold + set -x color_initial_segment_jobs grey blue --bold + + set -x color_path brgrey white + set -x color_path_basename brgrey white --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree brgrey $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_username brgrey white --bold + set -x color_hostname brgrey white + set -x color_rvm brmagenta $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + + case 'terminal2-light*' + set -l colorfg white + [ "$color_scheme" = 'terminal2-light-black' ]; and set colorfg black + set -x color_initial_segment_exit brgrey red --bold + set -x color_initial_segment_su brgrey green --bold + set -x color_initial_segment_jobs brgrey blue --bold + + set -x color_path grey black + set -x color_path_basename grey black --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree grey $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_username grey black --bold + set -x color_hostname grey black + set -x color_rvm brmagenta $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + + case 'zenburn' + set -l grey 333333 # a bit darker than normal zenburn grey + set -l red CC9393 + set -l green 7F9F7F + set -l yellow E3CEAB + set -l orange DFAF8F + set -l blue 8CD0D3 + set -l white DCDCCC + + set -x color_initial_segment_exit $white $red --bold + set -x color_initial_segment_su $white $green --bold + set -x color_initial_segment_jobs $white $blue --bold + + set -x color_path $grey $white + set -x color_path_basename $grey $white --bold + set -x color_path_nowrite $grey $red + set -x color_path_nowrite_basename $grey $red --bold + + set -x color_repo $green $grey + set -x color_repo_work_tree $grey $grey --bold + set -x color_repo_dirty $red $grey + set -x color_repo_staged $yellow $grey + + set -x color_vi_mode_default $grey $yellow --bold + set -x color_vi_mode_insert $green $white --bold + set -x color_vi_mode_visual $yellow $grey --bold + + set -x color_vagrant $blue $green --bold + set -x color_k8s $green $white --bold + set -x color_username $grey $blue --bold + set -x color_hostname $grey $blue + set -x color_rvm $red $grey --bold + set -x color_virtualfish $blue $grey --bold + set -x color_virtualgo $blue $grey --bold + set -x color_desk $blue $grey --bold + + case 'base16-light' + set -l base00 181818 + set -l base01 282828 + set -l base02 383838 + set -l base03 585858 + set -l base04 b8b8b8 + set -l base05 d8d8d8 + set -l base06 e8e8e8 + set -l base07 f8f8f8 + set -l base08 ab4642 # red + set -l base09 dc9656 # orange + set -l base0A f7ca88 # yellow + set -l base0B a1b56c # green + set -l base0C 86c1b9 # cyan + set -l base0D 7cafc2 # blue + set -l base0E ba8baf # violet + set -l base0F a16946 # brown + + set -l colorfg $base00 + + set -x color_initial_segment_exit $base02 $base08 --bold + set -x color_initial_segment_su $base02 $base0B --bold + set -x color_initial_segment_jobs $base02 $base0D --bold + + set -x color_path $base06 $base02 + set -x color_path_basename $base06 $base01 --bold + set -x color_path_nowrite $base06 $base08 + set -x color_path_nowrite_basename $base06 $base08 --bold + + set -x color_repo $base0B $colorfg + set -x color_repo_work_tree $base06 $colorfg --bold + set -x color_repo_dirty $base08 $colorfg + set -x color_repo_staged $base09 $colorfg + + set -x color_vi_mode_default $base04 $colorfg --bold + set -x color_vi_mode_insert $base0B $colorfg --bold + set -x color_vi_mode_visual $base09 $colorfg --bold + + set -x color_vagrant $base0C $colorfg --bold + set -x color_k8s $base06 $colorfg --bold + set -x color_username $base02 $base0D --bold + set -x color_hostname $base02 $base0D + set -x color_rvm $base08 $colorfg --bold + set -x color_virtualfish $base0D $colorfg --bold + set -x color_virtualgo $base0D $colorfg --bold + set -x color_desk $base0D $colorfg --bold + + case 'base16' 'base16-dark' + set -l base00 181818 + set -l base01 282828 + set -l base02 383838 + set -l base03 585858 + set -l base04 b8b8b8 + set -l base05 d8d8d8 + set -l base06 e8e8e8 + set -l base07 f8f8f8 + set -l base08 ab4642 # red + set -l base09 dc9656 # orange + set -l base0A f7ca88 # yellow + set -l base0B a1b56c # green + set -l base0C 86c1b9 # cyan + set -l base0D 7cafc2 # blue + set -l base0E ba8baf # violet + set -l base0F a16946 # brown + + set -l colorfg $base07 + + set -x color_initial_segment_exit $base05 $base08 --bold + set -x color_initial_segment_su $base05 $base0B --bold + set -x color_initial_segment_jobs $base05 $base0D --bold + + set -x color_path $base02 $base05 + set -x color_path_basename $base02 $base06 --bold + set -x color_path_nowrite $base02 $base08 + set -x color_path_nowrite_basename $base02 $base08 --bold + + set -x color_repo $base0B $colorfg + set -x color_repo_work_tree $base02 $colorfg --bold + set -x color_repo_dirty $base08 $colorfg + set -x color_repo_staged $base09 $colorfg + + set -x color_vi_mode_default $base03 $colorfg --bold + set -x color_vi_mode_insert $base0B $colorfg --bold + set -x color_vi_mode_visual $base09 $colorfg --bold + + set -x color_vagrant $base0C $colorfg --bold + set -x color_k8s $base0B $colorfg --bold + set -x color_username $base02 $base0D --bold + set -x color_hostname $base02 $base0D + set -x color_rvm $base08 $colorfg --bold + set -x color_virtualfish $base0D $colorfg --bold + set -x color_virtualgo $base0D $colorfg --bold + set -x color_desk $base0D $colorfg --bold + + case 'solarized-light' + set -l base03 002b36 + set -l base02 073642 + set -l base01 586e75 + set -l base00 657b83 + set -l base0 839496 + set -l base1 93a1a1 + set -l base2 eee8d5 + set -l base3 fdf6e3 + set -l yellow b58900 + set -l orange cb4b16 + set -l red dc322f + set -l magenta d33682 + set -l violet 6c71c4 + set -l blue 268bd2 + set -l cyan 2aa198 + set -l green 859900 + + set colorfg $base03 + + set -x color_initial_segment_exit $base02 $red --bold + set -x color_initial_segment_su $base02 $green --bold + set -x color_initial_segment_jobs $base02 $blue --bold + + set -x color_path $base2 $base00 + set -x color_path_basename $base2 $base01 --bold + set -x color_path_nowrite $base2 $orange + set -x color_path_nowrite_basename $base2 $orange --bold + + set -x color_repo $green $colorfg + set -x color_repo_work_tree $base2 $colorfg --bold + set -x color_repo_dirty $red $colorfg + set -x color_repo_staged $yellow $colorfg + + set -x color_vi_mode_default $blue $colorfg --bold + set -x color_vi_mode_insert $green $colorfg --bold + set -x color_vi_mode_visual $yellow $colorfg --bold + + set -x color_vagrant $violet $colorfg --bold + set -x color_k8s $green $colorfg --bold + set -x color_username $base2 $blue --bold + set -x color_hostname $base2 $blue + set -x color_rvm $red $colorfg --bold + set -x color_virtualfish $cyan $colorfg --bold + set -x color_virtualgo $cyan $colorfg --bold + set -x color_desk $cyan $colorfg --bold + + case 'solarized' 'solarized-dark' + set -l base03 002b36 + set -l base02 073642 + set -l base01 586e75 + set -l base00 657b83 + set -l base0 839496 + set -l base1 93a1a1 + set -l base2 eee8d5 + set -l base3 fdf6e3 + set -l yellow b58900 + set -l orange cb4b16 + set -l red dc322f + set -l magenta d33682 + set -l violet 6c71c4 + set -l blue 268bd2 + set -l cyan 2aa198 + set -l green 859900 + + set colorfg $base3 + + set -x color_initial_segment_exit $base2 $red --bold + set -x color_initial_segment_su $base2 $green --bold + set -x color_initial_segment_jobs $base2 $blue --bold + + set -x color_path $base02 $base0 + set -x color_path_basename $base02 $base1 --bold + set -x color_path_nowrite $base02 $orange + set -x color_path_nowrite_basename $base02 $orange --bold + + set -x color_repo $green $colorfg + set -x color_repo_work_tree $base02 $colorfg --bold + set -x color_repo_dirty $red $colorfg + set -x color_repo_staged $yellow $colorfg + + set -x color_vi_mode_default $blue $colorfg --bold + set -x color_vi_mode_insert $green $colorfg --bold + set -x color_vi_mode_visual $yellow $colorfg --bold + + set -x color_vagrant $violet $colorfg --bold + set -x color_k8s $green $colorfg --bold + set -x color_username $base02 $blue --bold + set -x color_hostname $base02 $blue + set -x color_rvm $red $colorfg --bold + set -x color_virtualfish $cyan $colorfg --bold + set -x color_virtualgo $cyan $colorfg --bold + set -x color_desk $cyan $colorfg --bold + + case 'light' + # light medium dark + # ------ ------ ------ + set -l red cc9999 ce000f 660000 + set -l green addc10 189303 0c4801 + set -l blue 48b4fb 005faf 255e87 + set -l orange f6b117 unused 3a2a03 + set -l brown bf5e00 803f00 4d2600 + set -l grey cccccc 999999 333333 + set -l white ffffff + set -l black 000000 + set -l ruby_red af0000 + + set -x color_initial_segment_exit $grey[3] $red[2] --bold + set -x color_initial_segment_su $grey[3] $green[2] --bold + set -x color_initial_segment_jobs $grey[3] $blue[3] --bold + + set -x color_path $grey[1] $grey[2] + set -x color_path_basename $grey[1] $grey[3] --bold + set -x color_path_nowrite $red[1] $red[3] + set -x color_path_nowrite_basename $red[1] $red[3] --bold + + set -x color_repo $green[1] $green[3] + set -x color_repo_work_tree $grey[1] $white --bold + set -x color_repo_dirty $red[2] $white + set -x color_repo_staged $orange[1] $orange[3] + + set -x color_vi_mode_default $grey[2] $grey[3] --bold + set -x color_vi_mode_insert $green[2] $grey[3] --bold + set -x color_vi_mode_visual $orange[1] $orange[3] --bold + + set -x color_vagrant $blue[1] $white --bold + set -x color_k8s $green[1] $colorfg --bold + set -x color_username $grey[1] $blue[3] --bold + set -x color_hostname $grey[1] $blue[3] + set -x color_rvm $ruby_red $grey[1] --bold + set -x color_virtualfish $blue[2] $grey[1] --bold + set -x color_virtualgo $blue[2] $grey[1] --bold + set -x color_desk $blue[2] $grey[1] --bold + + case 'gruvbox' + # light medium dark darkest + # ------ ------ ------ ------- + set -l red fb4934 cc241d + set -l green b8bb26 98971a + set -l yellow fabd2f d79921 + set -l aqua 8ec07c 689d6a + set -l blue 83a598 458588 + set -l grey cccccc 999999 333333 + set -l fg fbf1c7 ebdbb2 d5c4a1 a89984 + set -l bg 504945 282828 + + set -x color_initial_segment_exit $fg[1] $red[2] --bold + set -x color_initial_segment_su $fg[1] $green[2] --bold + set -x color_initial_segment_jobs $fg[1] $aqua[2] --bold + + set -x color_path $bg[1] $fg[2] + set -x color_path_basename $bg[1] $fg[2] --bold + set -x color_path_nowrite $red[1] $fg[2] + set -x color_path_nowrite_basename $red[1] $fg[2] --bold + + set -x color_repo $green[2] $bg[1] + set -x color_repo_work_tree $bg[1] $fg[2] --bold + set -x color_repo_dirty $red[2] $fg[2] + set -x color_repo_staged $yellow[1] $bg[1] + + set -x color_vi_mode_default $fg[4] $bg[2] --bold + set -x color_vi_mode_insert $blue[1] $bg[2] --bold + set -x color_vi_mode_visual $yellow[1] $bg[2] --bold + + set -x color_vagrant $blue[2] $fg[2] --bold + set -x color_k8s $green[2] $fg[2] --bold + set -x color_username $fg[3] $blue[2] --bold + set -x color_hostname $fg[3] $blue[2] + set -x color_rvm $red[2] $fg[2] --bold + set -x color_virtualfish $blue[2] $fg[2] --bold + set -x color_virtualgo $blue[2] $fg[2] --bold + set -x color_desk $blue[2] $fg[2] --bold + + case '*' # default dark theme + # light medium dark + # ------ ------ ------ + set -l red cc9999 ce000f 660000 + set -l green addc10 189303 0c4801 + set -l blue 48b4fb 005faf 255e87 + set -l orange f6b117 unused 3a2a03 + set -l brown bf5e00 803f00 4d2600 + set -l grey cccccc 999999 333333 + set -l white ffffff + set -l black 000000 + set -l ruby_red af0000 + set -l go_blue 00d7d7 + + set -x color_initial_segment_exit $white $red[2] --bold + set -x color_initial_segment_su $white $green[2] --bold + set -x color_initial_segment_jobs $white $blue[3] --bold + + set -x color_path $grey[3] $grey[2] + set -x color_path_basename $grey[3] $white --bold + set -x color_path_nowrite $red[3] $red[1] + set -x color_path_nowrite_basename $red[3] $red[1] --bold + + set -x color_repo $green[1] $green[3] + set -x color_repo_work_tree $grey[3] $white --bold + set -x color_repo_dirty $red[2] $white + set -x color_repo_staged $orange[1] $orange[3] + + set -x color_vi_mode_default $grey[2] $grey[3] --bold + set -x color_vi_mode_insert $green[2] $grey[3] --bold + set -x color_vi_mode_visual $orange[1] $orange[3] --bold + + set -x color_vagrant $blue[1] $white --bold + set -x color_k8s $green[2] $white --bold + set -x color_username $grey[1] $blue[3] --bold + set -x color_hostname $grey[1] $blue[3] + set -x color_rvm $ruby_red $grey[1] --bold + set -x color_virtualfish $blue[2] $grey[1] --bold + set -x color_virtualgo $go_blue $black --bold + set -x color_desk $blue[2] $grey[1] --bold + end +end + +function __bobthefish_user_color_scheme_deprecated + set -q __color_initial_segment_exit; or set -l __color_initial_segment_exit ffffff ce000f --bold + set -q __color_initial_segment_su; or set -l __color_initial_segment_su ffffff 189303 --bold + set -q __color_initial_segment_jobs; or set -l __color_initial_segment_jobs ffffff 255e87 --bold + set -q __color_path; or set -l __color_path 333333 999999 + set -q __color_path_basename; or set -l __color_path_basename 333333 ffffff --bold + set -q __color_path_nowrite; or set -l __color_path_nowrite 660000 cc9999 + set -q __color_path_nowrite_basename; or set -l __color_path_nowrite_basename 660000 cc9999 --bold + set -q __color_repo; or set -l __color_repo addc10 0c4801 + set -q __color_repo_work_tree; or set -l __color_repo_work_tree 333333 ffffff --bold + set -q __color_repo_dirty; or set -l __color_repo_dirty ce000f ffffff + set -q __color_repo_staged; or set -l __color_repo_staged f6b117 3a2a03 + set -q __color_vi_mode_default; or set -l __color_vi_mode_default 999999 333333 --bold + set -q __color_vi_mode_insert; or set -l __color_vi_mode_insert 189303 333333 --bold + set -q __color_vi_mode_visual; or set -l __color_vi_mode_visual f6b117 3a2a03 --bold + set -q __color_vagrant; or set -l __color_vagrant 48b4fb ffffff --bold + set -q __color_username; or set -l __color_username cccccc 255e87 --bold + set -q __color_hostname; or set -l __color_hostname cccccc 255e87 + set -q __color_rvm; or set -l __color_rvm af0000 cccccc --bold + set -q __color_virtualfish; or set -l __color_virtualfish 005faf cccccc --bold + set -q __color_virtualgo; or set -l __color_virtualgo 005faf cccccc --bold + set -q __color_desk; or set -l __color_desk 005faf cccccc --bold + + set_color black -b red --bold + echo "The 'user' color scheme is deprecated." + set_color normal + set_color black -b red + echo "To define a custom color scheme, create a 'bobthefish_colors' function:" + set_color normal + echo + + echo "function bobthefish_colors -S -d 'Define a custom bobthefish color scheme' + + # optionally include a base color scheme... + ___bobthefish_colors default + + # then override everything you want! note that these must be defined with `set -x` + set -x color_initial_segment_exit $__color_initial_segment_exit + set -x color_initial_segment_su $__color_initial_segment_su + set -x color_initial_segment_jobs $__color_initial_segment_jobs + set -x color_path $__color_path + set -x color_path_basename $__color_path_basename + set -x color_path_nowrite $__color_path_nowrite + set -x color_path_nowrite_basename $__color_path_nowrite_basename + set -x color_repo $__color_repo + set -x color_repo_work_tree $__color_repo_work_tree + set -x color_repo_dirty $__color_repo_dirty + set -x color_repo_staged $__color_repo_staged + set -x color_vi_mode_default $__color_vi_mode_default + set -x color_vi_mode_insert $__color_vi_mode_insert + set -x color_vi_mode_visual $__color_vi_mode_visual + set -x color_vagrant $__color_vagrant + set -x color_username $__color_username + set -x color_hostname $__color_hostname + set -x color_rvm $__color_rvm + set -x color_virtualfish $__color_virtualfish + set -x color_virtualgo $__color_virtualgo + set -x color_desk $__color_desk +end" + + echo +end diff --git a/functions/__bobthefish_display_colors.fish b/functions/__bobthefish_display_colors.fish new file mode 100644 index 0000000..210a803 --- /dev/null +++ b/functions/__bobthefish_display_colors.fish @@ -0,0 +1,3 @@ +function __bobthefish_display_colors -d 'Print example prompts using the current color scheme' + bobthefish_display_colors +end diff --git a/functions/__bobthefish_glyphs.fish b/functions/__bobthefish_glyphs.fish new file mode 100644 index 0000000..2e8a8f1 --- /dev/null +++ b/functions/__bobthefish_glyphs.fish @@ -0,0 +1,89 @@ +function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish' + # Powerline glyphs + set -x branch_glyph \uE0A0 + set -x right_black_arrow_glyph \uE0B0 + set -x right_arrow_glyph \uE0B1 + set -x left_black_arrow_glyph \uE0B2 + set -x left_arrow_glyph \uE0B3 + + # Additional glyphs + set -x detached_glyph \u27A6 + set -x tag_glyph \u2302 + set -x nonzero_exit_glyph '! ' + set -x superuser_glyph '$ ' + set -x bg_job_glyph '% ' + set -x hg_glyph \u263F + + # Python glyphs + set -x superscript_glyph \u00B9 \u00B2 \u00B3 + set -x virtualenv_glyph \u25F0 + set -x pypy_glyph \u1D56 + + set -x ruby_glyph '' + set -x go_glyph '' + + # Desk glyphs + set -x desk_glyph \u25F2 + + # Vagrant glyphs + set -x vagrant_running_glyph \u2191 # ↑ 'running' + set -x vagrant_poweroff_glyph \u2193 # ↓ 'poweroff' + set -x vagrant_aborted_glyph \u2715 # ✕ 'aborted' + set -x vagrant_saved_glyph \u21E1 # ⇡ 'saved' + set -x vagrant_stopping_glyph \u21E3 # ⇣ 'stopping' + set -x vagrant_unknown_glyph '!' # strange cases + + # Git glyphs + set -x git_dirty_glyph '*' + set -x git_staged_glyph '~' + set -x git_stashed_glyph '$' + set -x git_untracked_glyph '…' + set -x git_ahead_glyph \u2191 # '↑' + set -x git_behind_glyph \u2193 # '↓' + set -x git_plus_glyph '+' + set -x git_minus_glyph '-' + set -x git_plus_minus_glyph '±' + + # Disable Powerline fonts + if [ "$theme_powerline_fonts" = "no" ] + set branch_glyph \u2387 + set right_black_arrow_glyph '' + set right_arrow_glyph '' + set left_black_arrow_glyph '' + set left_arrow_glyph '' + end + + # Use prettier Nerd Fonts glyphs + if [ "$theme_nerd_fonts" = "yes" ] + set branch_glyph \uF418 + set detached_glyph \uF417 + set tag_glyph \uF412 + + set virtualenv_glyph \uE73C ' ' + set ruby_glyph \uE791 ' ' + set go_glyph \uE626 ' ' + + set vagrant_running_glyph \uF431 # ↑ 'running' + set vagrant_poweroff_glyph \uF433 # ↓ 'poweroff' + set vagrant_aborted_glyph \uF468 # ✕ 'aborted' + set vagrant_unknown_glyph \uF421 # strange cases + + set git_dirty_glyph \uF448 '' # nf-oct-pencil + set git_staged_glyph \uF0C7 '' # nf-fa-save + set git_stashed_glyph \uF0C6 '' # nf-fa-paperclip + set git_untracked_glyph \uF128 '' # nf-fa-question + # set git_untracked_glyph \uF141 '' # nf-fa-ellipsis_h + + set git_ahead_glyph \uF47B # nf-oct-chevron_up + set git_behind_glyph \uF47C # nf-oct-chevron_down + + set git_plus_glyph \uF0DE # fa-sort-asc + set git_minus_glyph \uF0DD # fa-sort-desc + set git_plus_minus_glyph \uF0DC # fa-sort + end + + # Avoid ambiguous glyphs + if [ "$theme_avoid_ambiguous_glyphs" = "yes" ] + set git_untracked_glyph '...' + end +end diff --git a/functions/bobthefish_display_colors.fish b/functions/bobthefish_display_colors.fish new file mode 100644 index 0000000..d9008af --- /dev/null +++ b/functions/bobthefish_display_colors.fish @@ -0,0 +1,132 @@ +function bobthefish_display_colors -a color_scheme -d 'Print example prompt color schemes' + + set -l color_schemes default light \ + solarized solarized-light \ + base16 base16-light \ + gruvbox zenburn \ + terminal terminal-dark-white \ + terminal-light terminal-light-black \ + terminal2 terminal2-dark-white \ + terminal2-light terminal2-light-black + + switch "$color_scheme" + case '--all' + for scheme in $color_schemes + echo + echo "$scheme:" + bobthefish_display_colors $scheme + end + return + + case $color_schemes + __bobthefish_colors $color_scheme + + case '' + __bobthefish_colors $theme_color_scheme + type -q bobthefish_colors + and bobthefish_colors + + case '*' + echo 'usage: bobthefish_display_colors [--all] [color_scheme]' + return + end + + __bobthefish_glyphs + + echo + set_color normal + + __bobthefish_start_segment $color_initial_segment_exit + echo -n exit '! ' + set_color -b $color_initial_segment_su + echo -n su '$ ' + set_color -b $color_initial_segment_jobs + echo -n jobs '% ' + __bobthefish_finish_segments + set_color normal + echo -n "(<- initial_segment)" + echo + + __bobthefish_start_segment $color_path + echo -n /color/path/ + set_color -b $color_path_basename + echo -ns basename ' ' + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_path_nowrite + echo -n /color/path/nowrite/ + set_color -b $color_path_nowrite_basename + echo -ns basename ' ' + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_path + echo -n /color/path/ + set_color -b $color_path_basename + echo -ns basename ' ' + __bobthefish_start_segment $color_repo + echo -n "$branch_glyph repo $git_stashed_glyph " + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_path + echo -n /color/path/ + set_color -b $color_path_basename + echo -ns basename ' ' + __bobthefish_start_segment $color_repo_dirty + echo -n "$tag_glyph repo_dirty $git_dirty_glyph " + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_path + echo -n /color/path/ + set_color -b $color_path_basename + echo -ns basename ' ' + __bobthefish_start_segment $color_repo_staged + echo -n "$detached_glyph repo_staged $git_staged_glyph " + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_vi_mode_default + echo -ns vi_mode_default ' ' + __bobthefish_finish_segments + __bobthefish_start_segment $color_vi_mode_insert + echo -ns vi_mode_insert ' ' + __bobthefish_finish_segments + __bobthefish_start_segment $color_vi_mode_visual + echo -ns vi_mode_visual ' ' + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_vagrant + echo -ns $vagrant_running_glyph ' ' vagrant ' ' + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_username + echo -n username + set_color normal + set_color -b $color_hostname[1] $color_hostname[2..-1] + echo -ns @hostname ' ' + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_rvm + echo -ns $ruby_glyph rvm ' ' + __bobthefish_finish_segments + + __bobthefish_start_segment $color_virtualfish + echo -ns $virtualenv_glyph virtualfish ' ' + __bobthefish_finish_segments + + __bobthefish_start_segment $color_virtualgo + echo -ns $go_glyph virtualgo ' ' + __bobthefish_finish_segments + + __bobthefish_start_segment $color_desk + echo -ns $desk_glyph desk ' ' + __bobthefish_finish_segments + + echo -e "\n" +end From 2428af06aacaccab6879b1732d4d704132a15252 Mon Sep 17 00:00:00 2001 From: Philip Schaten Date: Sun, 18 Mar 2018 23:10:06 +0100 Subject: [PATCH 18/20] theme_display_ssh - switch added --- README.md | 2 ++ fish_prompt.fish | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73e8d26..06b7117 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ set -g theme_display_virtualenv no set -g theme_display_ruby no set -g theme_display_user yes set -g theme_display_hostname yes +set -h theme_display_ssh yes set -g theme_display_vi no set -g theme_display_date no set -g theme_display_cmd_duration yes @@ -119,6 +120,7 @@ set -g theme_newline_cursor yes - `fish_prompt_pwd_dir_length`. bobthefish respects the Fish `$fish_prompt_pwd_dir_length` setting to abbreviate the prompt path. Set to `0` to show the full path, `1` (default) to show only the first character of each parent directory name, or any other number to show up to that many characters. - `theme_project_dir_length`. The same as `$fish_prompt_pwd_dir_length`, but for the path relative to the current project root. Defaults to `0`; set to any other number to show an abbreviated path. - `theme_newline_cursor`. Use `yes` to have cursor start on a new line. By default the prompt is only one line. When working with long directories it may be preferrend to have cursor on the next line. Setting this to `clean` instead of `yes` suppresses the caret on the new line. +- `theme_display_ssh`. Use `no` to hide user- and hostname in ssh-sessions. **Color scheme options** diff --git a/fish_prompt.fish b/fish_prompt.fish index 0d4ccf1..1ea652e 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -32,6 +32,7 @@ # set -g theme_display_ruby no # set -g theme_display_user yes # set -g theme_display_hostname yes +# set -g theme_display_ssh yes # set -g theme_display_vi no # set -g theme_avoid_ambiguous_glyphs yes # set -g theme_powerline_fonts no @@ -536,9 +537,9 @@ end # ============================== function __bobthefish_prompt_user -S -d 'Display current user and hostname' - [ "$theme_display_user" = 'yes' -o -n "$SSH_CLIENT" -o \( -n "$default_user" -a "$USER" != "$default_user" \) ] + [ "$theme_display_user" = 'yes' -o \( "$theme_display_ssh" = 'yes' -a -n "$SSH_CLIENT" \) -o \( -n "$default_user" -a "$USER" != "$default_user" \) ] and set -l display_user - [ "$theme_display_hostname" = 'yes' -o -n "$SSH_CLIENT" ] + [ "$theme_display_hostname" = 'yes' -o \( "$theme_display_ssh" = 'yes' -a -n "$SSH_CLIENT" \) ] and set -l display_hostname if set -q display_user From 89ca08abc4ed0d36d94835219fd7d9cb37bf53f8 Mon Sep 17 00:00:00 2001 From: Philip Schaten Date: Sun, 18 Mar 2018 23:12:22 +0100 Subject: [PATCH 19/20] theme_display_ssh defaults to no --- README.md | 4 ++-- fish_prompt.fish | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 06b7117..9f56f65 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ set -g theme_display_virtualenv no set -g theme_display_ruby no set -g theme_display_user yes set -g theme_display_hostname yes -set -h theme_display_ssh yes +set -h theme_display_ssh no set -g theme_display_vi no set -g theme_display_date no set -g theme_display_cmd_duration yes @@ -120,7 +120,7 @@ set -g theme_newline_cursor yes - `fish_prompt_pwd_dir_length`. bobthefish respects the Fish `$fish_prompt_pwd_dir_length` setting to abbreviate the prompt path. Set to `0` to show the full path, `1` (default) to show only the first character of each parent directory name, or any other number to show up to that many characters. - `theme_project_dir_length`. The same as `$fish_prompt_pwd_dir_length`, but for the path relative to the current project root. Defaults to `0`; set to any other number to show an abbreviated path. - `theme_newline_cursor`. Use `yes` to have cursor start on a new line. By default the prompt is only one line. When working with long directories it may be preferrend to have cursor on the next line. Setting this to `clean` instead of `yes` suppresses the caret on the new line. -- `theme_display_ssh`. Use `no` to hide user- and hostname in ssh-sessions. +- `theme_display_ssh`. Use `yes` to display user- and hostname in ssh-sessions, even if they're not shown normally. **Color scheme options** diff --git a/fish_prompt.fish b/fish_prompt.fish index 1ea652e..d09bfb1 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -32,7 +32,7 @@ # set -g theme_display_ruby no # set -g theme_display_user yes # set -g theme_display_hostname yes -# set -g theme_display_ssh yes +# set -g theme_display_ssh no # set -g theme_display_vi no # set -g theme_avoid_ambiguous_glyphs yes # set -g theme_powerline_fonts no From f66bee227acbe1e744c8b609963d8bbf1fe87a3c Mon Sep 17 00:00:00 2001 From: Philip Schaten Date: Fri, 23 Mar 2018 00:37:03 +0100 Subject: [PATCH 20/20] Allow three values for theme_display_user. --- README.md | 8 ++++---- fish_prompt.fish | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9f56f65..d1aa885 100644 --- a/README.md +++ b/README.md @@ -80,9 +80,8 @@ set -g theme_display_k8s_context yes set -g theme_display_hg yes set -g theme_display_virtualenv no set -g theme_display_ruby no -set -g theme_display_user yes -set -g theme_display_hostname yes -set -h theme_display_ssh no +set -g theme_display_user ssh +set -g theme_display_hostname ssh set -g theme_display_vi no set -g theme_display_date no set -g theme_display_cmd_duration yes @@ -115,12 +114,13 @@ set -g theme_newline_cursor yes - `theme_display_vagrant`. This feature is disabled by default, use `yes` to display Vagrant status in your prompt. Please note that only the VirtualBox and VMWare providers are supported. - `theme_display_vi`. By default the vi mode indicator will be shown if vi or hybrid key bindings are enabled. Use `no` to hide the indicator, or `yes` to show the indicator. - `theme_display_k8s_context`. By default the current kubernetes context is shown (`> kubectl config current-context`). Use `no` to hide the context. +- `theme_display_user`. If set to `yes`, display username always, if set to `ssh`, only when an SSH-Session is detected, if set to no, never. +- `theme_display_hostname`. Same behaviour as `theme_display`. - `theme_show_exit_status`. Set this option to yes to have the prompt show the last exit code if it was non_zero instead of just the exclamation mark. - `theme_git_worktree_support`. If you do any git worktree shenanigans, setting this to `yes` will fix incorrect project-relative path display. If you don't do any git worktree shenanigans, leave it disabled. It's faster this way :) - `fish_prompt_pwd_dir_length`. bobthefish respects the Fish `$fish_prompt_pwd_dir_length` setting to abbreviate the prompt path. Set to `0` to show the full path, `1` (default) to show only the first character of each parent directory name, or any other number to show up to that many characters. - `theme_project_dir_length`. The same as `$fish_prompt_pwd_dir_length`, but for the path relative to the current project root. Defaults to `0`; set to any other number to show an abbreviated path. - `theme_newline_cursor`. Use `yes` to have cursor start on a new line. By default the prompt is only one line. When working with long directories it may be preferrend to have cursor on the next line. Setting this to `clean` instead of `yes` suppresses the caret on the new line. -- `theme_display_ssh`. Use `yes` to display user- and hostname in ssh-sessions, even if they're not shown normally. **Color scheme options** diff --git a/fish_prompt.fish b/fish_prompt.fish index d09bfb1..7a71f7b 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -30,9 +30,8 @@ # set -g theme_display_hg yes # set -g theme_display_virtualenv no # set -g theme_display_ruby no -# set -g theme_display_user yes -# set -g theme_display_hostname yes -# set -g theme_display_ssh no +# set -g theme_display_user ssh +# set -g theme_display_hostname ssh # set -g theme_display_vi no # set -g theme_avoid_ambiguous_glyphs yes # set -g theme_powerline_fonts no @@ -537,9 +536,9 @@ end # ============================== function __bobthefish_prompt_user -S -d 'Display current user and hostname' - [ "$theme_display_user" = 'yes' -o \( "$theme_display_ssh" = 'yes' -a -n "$SSH_CLIENT" \) -o \( -n "$default_user" -a "$USER" != "$default_user" \) ] + [ "$theme_display_user" = 'yes' -o \( "$theme_display_user" != 'no' -a -n "$SSH_CLIENT" \) -o \( -n "$default_user" -a "$USER" != "$default_user" \) ] and set -l display_user - [ "$theme_display_hostname" = 'yes' -o \( "$theme_display_ssh" = 'yes' -a -n "$SSH_CLIENT" \) ] + [ "$theme_display_hostname" = 'yes' -o \( "$theme_display_hostname" != 'no' -a -n "$SSH_CLIENT" \) ] and set -l display_hostname if set -q display_user