From 9c95244b424b35a2ba09441a331fef27d23f2fd8 Mon Sep 17 00:00:00 2001 From: marcplustwo <39213657+marcplustwo@users.noreply.github.com> Date: Tue, 3 Dec 2019 17:59:18 +0100 Subject: [PATCH 01/18] add nord color scheme --- README.md | 1 + functions/__bobthefish_colors.fish | 48 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/README.md b/README.md index 05a22de..00aa6a0 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,7 @@ one of the following options to change the prompt colors. - `zenburn`. An adaptation of Zenburn. - `gruvbox`. An adaptation of gruvbox. - `dracula`. An adaptation of dracula. +- `nord`. An adaptation of nord. Some of these may not look right if your terminal does not support 24 bit color, in which case you can try one of the `terminal` schemes (below). However, if diff --git a/functions/__bobthefish_colors.fish b/functions/__bobthefish_colors.fish index 04f0307..5d46a7c 100644 --- a/functions/__bobthefish_colors.fish +++ b/functions/__bobthefish_colors.fish @@ -480,6 +480,54 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo $cyan $bg --bold set -x color_desk $comment $bg --bold + case 'nord' + set -l base00 2E3440 + set -l base01 3B4252 + set -l base02 434C5E + set -l base03 4C566A + set -l base04 D8DEE9 + set -l base05 E5E9F0 + set -l base06 ECEFF4 + set -l base07 8FBCBB + set -l base08 88C0D0 + set -l base09 81A1C1 + set -l base0A 5E81AC + set -l base0B BF616A + set -l base0C D08770 + set -l base0D EBCB8B + set -l base0E A3BE8C + set -l base0F B48EAD + + set -l colorfg $base00 + + set -x color_initial_segment_exit $base05 $base08 --bold + set -x color_initial_segment_su $base05 $base0B --bold + set -x color_initial_segment_jobs $base08 $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 $base0E $colorfg + set -x color_repo_work_tree $base02 $colorfg --bold + set -x color_repo_dirty $base0B $colorfg + set -x color_repo_staged $base0D $colorfg + + set -x color_vi_mode_default $base08 $colorfg --bold + set -x color_vi_mode_insert $base06 $colorfg --bold + set -x color_vi_mode_visual $base07 $colorfg --bold + + set -x color_vagrant $base02 $colorfg --bold + set -x color_k8s $base02 $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_nvm $base08 $colorfg --bold + set -x color_virtualfish $base08 $colorfg --bold + set -x color_virtualgo $base08 $colorfg --bold + set -x color_desk $base08 $colorfg --bold + case '*' # default dark theme # light medium dark # ------ ------ ------ From 0d2525e923dd47c90dc8cf749421682e1dc1f9f9 Mon Sep 17 00:00:00 2001 From: Marc <39213657+marcplustwo@users.noreply.github.com> Date: Tue, 7 Jan 2020 14:40:41 +0100 Subject: [PATCH 02/18] fix background job colors --- functions/__bobthefish_colors.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/__bobthefish_colors.fish b/functions/__bobthefish_colors.fish index 5d46a7c..3048bfb 100644 --- a/functions/__bobthefish_colors.fish +++ b/functions/__bobthefish_colors.fish @@ -502,7 +502,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_initial_segment_exit $base05 $base08 --bold set -x color_initial_segment_su $base05 $base0B --bold - set -x color_initial_segment_jobs $base08 $base0D --bold + set -x color_initial_segment_jobs $base05 $base0C --bold set -x color_path $base02 $base05 set -x color_path_basename $base02 $base06 --bold From 82a0a44cdcec1f225a99fa69fab5ca358b829b6a Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 17 Jan 2020 14:33:42 -0800 Subject: [PATCH 03/18] In the prompt, show user info before everything else --- fish_prompt.fish | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 470d142..02e03e5 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -1064,14 +1064,14 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' __bobthefish_prompt_status $last_status __bobthefish_prompt_vi + # User / hostname info + __bobthefish_prompt_user + # Containers and VMs __bobthefish_prompt_vagrant __bobthefish_prompt_docker __bobthefish_prompt_k8s_context - # User / hostname info - __bobthefish_prompt_user - # Virtual environments __bobthefish_prompt_desk __bobthefish_prompt_rubies From 10b19564aea2c4a5d87f25c40723d61b706bda99 Mon Sep 17 00:00:00 2001 From: Marc <39213657+marcplustwo@users.noreply.github.com> Date: Tue, 21 Jan 2020 14:53:55 +0100 Subject: [PATCH 04/18] fix indents, color contrast --- functions/__bobthefish_colors.fish | 42 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/functions/__bobthefish_colors.fish b/functions/__bobthefish_colors.fish index 3048bfb..8b25309 100644 --- a/functions/__bobthefish_colors.fish +++ b/functions/__bobthefish_colors.fish @@ -482,27 +482,27 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe case 'nord' set -l base00 2E3440 - set -l base01 3B4252 - set -l base02 434C5E - set -l base03 4C566A - set -l base04 D8DEE9 - set -l base05 E5E9F0 - set -l base06 ECEFF4 - set -l base07 8FBCBB - set -l base08 88C0D0 - set -l base09 81A1C1 - set -l base0A 5E81AC - set -l base0B BF616A - set -l base0C D08770 - set -l base0D EBCB8B - set -l base0E A3BE8C - set -l base0F B48EAD + set -l base01 3B4252 + set -l base02 434C5E + set -l base03 4C566A + set -l base04 D8DEE9 + set -l base05 E5E9F0 + set -l base06 ECEFF4 + set -l base07 8FBCBB + set -l base08 88C0D0 + set -l base09 81A1C1 + set -l base0A 5E81AC + set -l base0B BF616A + set -l base0C D08770 + set -l base0D EBCB8B + set -l base0E A3BE8C + set -l base0F B48EAD set -l colorfg $base00 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 $base0C --bold + set -x color_initial_segment_jobs $base08 $base0D --bold set -x color_path $base02 $base05 set -x color_path_basename $base02 $base06 --bold @@ -522,11 +522,11 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_k8s $base02 $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_nvm $base08 $colorfg --bold - set -x color_virtualfish $base08 $colorfg --bold - set -x color_virtualgo $base08 $colorfg --bold - set -x color_desk $base08 $colorfg --bold + set -x color_rvm $base09 $colorfg --bold + set -x color_nvm $base09 $colorfg --bold + set -x color_virtualfish $base09 $colorfg --bold + set -x color_virtualgo $base09 $colorfg --bold + set -x color_desk $base09 $colorfg --bold case '*' # default dark theme # light medium dark From 7d6f9634ac82f9786cd305f0cc8b5e8233e1feda Mon Sep 17 00:00:00 2001 From: Marc Radau Date: Tue, 21 Jan 2020 15:11:02 +0100 Subject: [PATCH 05/18] Add screenshot to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 00aa6a0..efa445b 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ set -g theme_newline_prompt '$ ' | ![solarized][solarized] | ![solarized-light][solarized-light] | | ![base16][base16] | ![base16-light][base16-light] | | ![zenburn][zenburn] | ![terminal-dark][terminal-dark] | +| ![nord][nord] | | You can use the function `bobthefish_display_colors` to preview the prompts in any color scheme. @@ -235,3 +236,4 @@ end [base16-light]: https://cloud.githubusercontent.com/assets/53660/16141579/02f7245e-3412-11e6-97c6-5f3cecffb73c.png "base16-light" [zenburn]: https://cloud.githubusercontent.com/assets/53660/16141580/06229dd4-3412-11e6-84aa-a48de127b6da.png "zenburn" [terminal-dark]: https://cloud.githubusercontent.com/assets/53660/16141583/0b3e8eea-3412-11e6-8068-617c5371f6ea.png "terminal-dark" +[nord]: https://user-images.githubusercontent.com/39213657/72811435-f64ca800-3c5f-11ea-8711-dcce8cfc50fb.png "nord" From 740150da19ee745fd6cf8b442f5dc5aca293a753 Mon Sep 17 00:00:00 2001 From: Alexander Olsson Date: Sat, 29 Feb 2020 18:39:32 +0100 Subject: [PATCH 06/18] Make displaying the k8s namespace optional Invoking the `kubectl` command can be expensive, and since there's not a lot of time to play with when rendering the prompt without it feeling slugging, make the namespace fetching optional. --- README.md | 1 + fish_prompt.fish | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 43ed9e4..dd78e50 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ set -g theme_newline_prompt '$ ' - `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`. This feature is disabled by default. Use `yes` to show the current kubernetes context (`> kubectl config current-context`). +- `theme_display_k8s_namespace`. This feature is disabled by default. Use `yes` to show the current kubernetes namespace. - `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_user`. - `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. diff --git a/fish_prompt.fish b/fish_prompt.fish index 29f8753..a1217d7 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -28,6 +28,7 @@ # set -g theme_display_vagrant yes # set -g theme_display_docker_machine no # set -g theme_display_k8s_context yes +# set -g theme_display_k8s_namespace no # set -g theme_display_hg yes # set -g theme_display_virtualenv no # set -g theme_display_ruby no @@ -627,7 +628,8 @@ function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context' set -l context (__bobthefish_k8s_context) or return - set -l namespace (__bobthefish_k8s_namespace) + [ "$theme_display_k8s_namespace" = 'yes' ] + and set -l namespace (__bobthefish_k8s_namespace) set -l segment $k8s_glyph " " $context [ -n "$namespace" ] From 46a89abb9918704ddce5489973e7d0caa865bd73 Mon Sep 17 00:00:00 2001 From: Eric Moyer Date: Mon, 16 Mar 2020 20:10:42 -0700 Subject: [PATCH 07/18] escape project_root_dir before using in regex --- fish_prompt.fish | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 5a86afd..879d1fc 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -231,7 +231,8 @@ function __bobthefish_project_pwd -S -a project_root_dir -a real_pwd -d 'Print t set -q theme_project_dir_length or set -l theme_project_dir_length 0 - set -l project_dir (string replace -r '^'"$project_root_dir"'($|/)' '' $real_pwd) + set -l project_root_dir_escaped (string escape --style=regex $project_root_dir) + set -l project_dir (string replace -r '^'"$project_root_dir_escaped"'($|/)' '' $real_pwd) if [ $theme_project_dir_length -eq 0 ] echo -n $project_dir From 0c3ae9f932e85de40fae742bac5e1eb005b34b87 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 17 Mar 2020 20:53:48 -0700 Subject: [PATCH 08/18] Fall back to unescaped strings in older Fish Because that's a lot better than erroring out :) --- fish_prompt.fish | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 879d1fc..e77b446 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -67,6 +67,13 @@ function __bobthefish_pwd -d 'Get a normalized $PWD' or echo $PWD end +# Note that for fish < 3.0 this falls back to unescaped, rather than trying to do something clever /shrug +# After we drop support for older fishies, we can inline this without the fallback. +function __bobthefish_escape_regex -a str -d 'A backwards-compatible `string escape --style=regex` implementation' + string escape --style=regex "$str" 2>/dev/null + or echo "$str" +end + function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' set -l ref (command git symbolic-ref HEAD 2>/dev/null) and begin @@ -231,8 +238,7 @@ function __bobthefish_project_pwd -S -a project_root_dir -a real_pwd -d 'Print t set -q theme_project_dir_length or set -l theme_project_dir_length 0 - set -l project_root_dir_escaped (string escape --style=regex $project_root_dir) - set -l project_dir (string replace -r '^'"$project_root_dir_escaped"'($|/)' '' $real_pwd) + set -l project_dir (string replace -r '^'(__bobthefish_escape_regex "$project_root_dir")'($|/)' '' $real_pwd) if [ $theme_project_dir_length -eq 0 ] echo -n $project_dir From 9dd917535a60210d48871f6c333f7d404c5845bb Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 17 Mar 2020 21:09:15 -0700 Subject: [PATCH 09/18] Escape home directory used in regex, too! --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index e77b446..a380214 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -110,7 +110,7 @@ function __bobthefish_pretty_parent -S -a child_dir -d 'Print a parent directory # Replace $HOME with ~ set -l real_home ~ - set -l parent_dir (string replace -r '^'"$real_home"'($|/)' '~$1' (__bobthefish_dirname $child_dir)) + set -l parent_dir (string replace -r '^'(__bobthefish_escape_regex "$real_home")'($|/)' '~$1' (__bobthefish_dirname $child_dir)) # Must check whether `$parent_dir = /` if using native dirname if [ -z "$parent_dir" ] From e4c6a5c43492eaf6eaf752a146af96c76996f977 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Mon, 20 Apr 2020 09:57:15 -0700 Subject: [PATCH 10/18] Fix key binding mode indicator in newer Fish Unfortunately this means we can't have a pretty arrow between the binding mode indicator and the rest of the prompt, but it's better than never updating the indicator :-/ Fixes #248 --- fish_mode_prompt.fish | 41 +++++++++++++++++++++++++++++++++++++---- fish_prompt.fish | 29 +---------------------------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/fish_mode_prompt.fish b/fish_mode_prompt.fish index 304b705..efb3c62 100644 --- a/fish_mode_prompt.fish +++ b/fish_mode_prompt.fish @@ -1,9 +1,42 @@ -# This is handled inside fish_mode_prompt (see `__bobthefish_prompt_vi`) +# Display the current binding mode... if it's vi or vi-like. # -# If you want to override this with your own mode prompt, disable bobthefish's -# built-in mode prompt in your fish config: +# To always show the binding mode (regardless of current bindings): +# set -g theme_display_vi yes # +# To never show: # set -g theme_display_vi no -function fish_mode_prompt +function fish_mode_prompt -d 'bobthefish-optimized fish mode indicator' + [ "$theme_display_vi" != 'no' ] + or return + + [ "$fish_key_bindings" = 'fish_vi_key_bindings' \ + -o "$fish_key_bindings" = 'hybrid_bindings' \ + -o "$fish_key_bindings" = 'fish_hybrid_key_bindings' \ + -o "$theme_display_vi" = 'yes' ] + or return + + __bobthefish_colors $theme_color_scheme + + type -q bobthefish_colors + and bobthefish_colors + + set_color normal # clear out anything bold or underline... + + switch $fish_bind_mode + case default + set_color -b $color_vi_mode_default + echo -n ' N ' + case insert + set_color -b $color_vi_mode_insert + echo -n ' I ' + case replace_one replace-one + set_color -b $color_vi_mode_insert + echo -n ' R ' + case visual + set_color -b $color_vi_mode_visual + echo -n ' V ' + end + + set_color normal end diff --git a/fish_prompt.fish b/fish_prompt.fish index a380214..7033587 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -407,7 +407,7 @@ end # ============================== -# Status and input mode segments +# Status segment # ============================== function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a non-zero exit status, root user, and background jobs' @@ -485,32 +485,6 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a no end end -function __bobthefish_prompt_vi -S -d 'Display vi mode' - [ "$theme_display_vi" != 'no' ] - or return - - [ "$fish_key_bindings" = 'fish_vi_key_bindings' \ - -o "$fish_key_bindings" = 'hybrid_bindings' \ - -o "$fish_key_bindings" = 'fish_hybrid_key_bindings' \ - -o "$theme_display_vi" = 'yes' ] - or return - - switch $fish_bind_mode - case default - __bobthefish_start_segment $color_vi_mode_default - echo -n 'N ' - case insert - __bobthefish_start_segment $color_vi_mode_insert - echo -n 'I ' - case replace_one replace-one - __bobthefish_start_segment $color_vi_mode_insert - echo -n 'R ' - case visual - __bobthefish_start_segment $color_vi_mode_visual - echo -n 'V ' - end -end - # ============================== # Container and VM segments @@ -1071,7 +1045,6 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' # Status flags and input mode __bobthefish_prompt_status $last_status - __bobthefish_prompt_vi # User / hostname info __bobthefish_prompt_user From 3b37ec9f0b72b2be1d9f2682bbb47eaf8ab64335 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Mon, 20 Apr 2020 10:37:09 -0700 Subject: [PATCH 11/18] Make bobthefish_display_colors current color theme more clear Fixes #247 --- functions/bobthefish_display_colors.fish | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/functions/bobthefish_display_colors.fish b/functions/bobthefish_display_colors.fish index 2abb5ab..b889449 100644 --- a/functions/bobthefish_display_colors.fish +++ b/functions/bobthefish_display_colors.fish @@ -23,8 +23,16 @@ function bobthefish_display_colors -a color_scheme -d 'Print example prompt colo __bobthefish_colors $color_scheme case '' - [ -n "$theme_color_scheme" ] - and echo "$theme_color_scheme:" + if type -q bobthefish_colors + if [ -n "$theme_color_scheme" ] + echo "$theme_color_scheme (with bobthefish_colors overrides):" + else + echo 'custom (via bobthefish_colors):' + end + else if [ -n "$theme_color_scheme" ] + echo "$theme_color_scheme:" + end + __bobthefish_colors $theme_color_scheme type -q bobthefish_colors and bobthefish_colors From 6e75f31c3fd10944b108b0338e855a993bad17c9 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 21 Apr 2020 13:54:19 -0700 Subject: [PATCH 12/18] Add timezone support to right prompt. Allow overriding the right prompt datestamp timezone: ``` set -g theme_date_timezone America/Los_Angeles ``` --- README.md | 1 + fish_right_prompt.fish | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e189c13..9893a1f 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ set -g theme_title_display_path no set -g theme_title_display_user yes set -g theme_title_use_abbreviated_path no set -g theme_date_format "+%a %H:%M" +set -g theme_date_timezone America/Los_Angeles set -g theme_avoid_ambiguous_glyphs yes set -g theme_powerline_fonts no set -g theme_nerd_fonts yes diff --git a/fish_right_prompt.fish b/fish_right_prompt.fish index d0bb3b1..c9e2c7a 100644 --- a/fish_right_prompt.fish +++ b/fish_right_prompt.fish @@ -1,5 +1,6 @@ # You can override some default right prompt options in your config.fish: # set -g theme_date_format "+%a %H:%M" +# set -g theme_date_timezone America/Los_Angeles function __bobthefish_cmd_duration -S -d 'Show command duration' [ "$theme_display_cmd_duration" = "no" ] @@ -62,7 +63,7 @@ function __bobthefish_timestamp -S -d 'Show the current timestamp' or set -l theme_date_format "+%c" echo -n ' ' - date $theme_date_format + env TZ="$theme_date_timezone" date $theme_date_format end function fish_right_prompt -d 'bobthefish is all about the right prompt' From 7c2d90152eb6a2f319c3927fa11adb7763f2ea6f Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 2 May 2020 08:29:34 -0700 Subject: [PATCH 13/18] Handle whitespace in asdf system ruby detection. Fixes #250 --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 7033587..42071d1 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -781,7 +781,7 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' or return # If asdf changes their ruby version provenance format, update this to match - [ "$asdf_provenance" = "(set by $HOME/.tool-versions)" ] + [ (string trim -- "$asdf_provenance") = "(set by $HOME/.tool-versions)" ] and return set ruby_version $asdf_ruby_version From 1f24d5f217a13881e6e089810f7a220e32ee8f86 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 2 May 2020 08:34:23 -0700 Subject: [PATCH 14/18] Better ruby segment output when adsf is installed but not configured. Previously it would add `No` as the ruby version, which was factually correct but not at all what we were looking for. This omits the ruby segment entirely if the adsf plugin for ruby is not installed, or if there is no current ruby version specified. --- fish_prompt.fish | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 42071d1..0a6a3f3 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -777,9 +777,11 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' else if type -q chruby # chruby is implemented as a function, so omitting the -f is intentional set ruby_version $RUBY_VERSION else if type -fq asdf - asdf current ruby 2>/dev/null | read -l asdf_ruby_version asdf_provenance + set -l asdf_current_ruby (asdf current ruby 2>/dev/null) or return + echo "$asdf_current_ruby" | read -l asdf_ruby_version asdf_provenance + # If asdf changes their ruby version provenance format, update this to match [ (string trim -- "$asdf_provenance") = "(set by $HOME/.tool-versions)" ] and return From aafed7cb24232121afef286f052b0d23e212bfae Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Wed, 6 Nov 2019 09:41:03 -0800 Subject: [PATCH 15/18] Add nix prompt, glyph, and colors --- fish_prompt.fish | 10 ++++++++++ functions/__bobthefish_colors.fish | 15 +++++++++++++++ functions/__bobthefish_glyphs.fish | 2 ++ 3 files changed, 27 insertions(+) diff --git a/fish_prompt.fish b/fish_prompt.fish index 0a6a3f3..dd209a0 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -859,6 +859,15 @@ function __bobthefish_prompt_nvm -S -d 'Display current node version through NVM set_color normal end +function __bobthefish_prompt_nix -S -d 'Display current nix environment' + [ "$theme_display_nix" = 'no' -o -z "$IN_NIX_SHELL" ] + and return + + __bobthefish_start_segment $color_nix + echo -ns $nix_glyph $IN_NIX_SHELL ' ' + + set_color normal +end # ============================== # VCS segments @@ -1057,6 +1066,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' __bobthefish_prompt_k8s_context # Virtual environments + __bobthefish_prompt_nix __bobthefish_prompt_desk __bobthefish_prompt_rubies __bobthefish_prompt_virtualfish diff --git a/functions/__bobthefish_colors.fish b/functions/__bobthefish_colors.fish index 8b25309..93be762 100644 --- a/functions/__bobthefish_colors.fish +++ b/functions/__bobthefish_colors.fish @@ -34,6 +34,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualfish brblue $colorfg --bold set -x color_virtualgo brblue $colorfg --bold set -x color_desk brblue $colorfg --bold + set -x color_nix brblue $colorfg --bold case 'terminal-light*' set -l colorfg white @@ -65,6 +66,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualfish brblue $colorfg --bold set -x color_virtualgo brblue $colorfg --bold set -x color_desk brblue $colorfg --bold + set -x color_nix brblue $colorfg --bold case 'terminal2' 'terminal2-dark*' set -l colorfg black @@ -96,6 +98,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualfish brblue $colorfg --bold set -x color_virtualgo brblue $colorfg --bold set -x color_desk brblue $colorfg --bold + set -x color_nix brblue $colorfg --bold case 'terminal2-light*' set -l colorfg white @@ -127,6 +130,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualfish brblue $colorfg --bold set -x color_virtualgo brblue $colorfg --bold set -x color_desk brblue $colorfg --bold + set -x color_nix brblue $colorfg --bold case 'zenburn' set -l grey 333333 # a bit darker than normal zenburn grey @@ -164,6 +168,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualfish $blue $grey --bold set -x color_virtualgo $blue $grey --bold set -x color_desk $blue $grey --bold + set -x color_nix $blue $grey --bold case 'base16-light' set -l base00 181818 @@ -212,6 +217,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualfish $base0D $colorfg --bold set -x color_virtualgo $base0D $colorfg --bold set -x color_desk $base0D $colorfg --bold + set -x color_nix $base0D $colorfg --bold case 'base16' 'base16-dark' set -l base00 181818 @@ -260,6 +266,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualfish $base0D $colorfg --bold set -x color_virtualgo $base0D $colorfg --bold set -x color_desk $base0D $colorfg --bold + set -x color_nix $base0D $colorfg --bold case 'solarized-light' set -l base03 002b36 @@ -308,6 +315,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualfish $cyan $colorfg --bold set -x color_virtualgo $cyan $colorfg --bold set -x color_desk $cyan $colorfg --bold + set -x color_nix $cyan $colorfg --bold case 'solarized' 'solarized-dark' set -l base03 002b36 @@ -356,6 +364,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualfish $cyan $colorfg --bold set -x color_virtualgo $cyan $colorfg --bold set -x color_desk $cyan $colorfg --bold + set -x color_nix $cyan $colorfg --bold case 'light' # light medium dark @@ -397,6 +406,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 + set -x color_nix $blue[2] $grey[1] --bold case 'gruvbox' # light medium dark darkest @@ -437,6 +447,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 + set -x color_nix $blue[2] $fg[2] --bold case 'dracula' # https://draculatheme.com set -l bg 282a36 @@ -479,6 +490,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualfish $comment $bg --bold set -x color_virtualgo $cyan $bg --bold set -x color_desk $comment $bg --bold + set -x color_nix $cyan $bg --bold case 'nord' set -l base00 2E3440 @@ -569,6 +581,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 + set -x color_nix $blue[2] $grey[1] --bold end end @@ -594,6 +607,7 @@ function __bobthefish_user_color_scheme_deprecated 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 -q __color_nix; or set -l __color_nix 005faf cccccc --bold set_color black -b red --bold echo "The 'user' color scheme is deprecated." @@ -630,6 +644,7 @@ function __bobthefish_user_color_scheme_deprecated set -x color_virtualfish $__color_virtualfish set -x color_virtualgo $__color_virtualgo set -x color_desk $__color_desk + set -x color_nix $__color_nix end" echo diff --git a/functions/__bobthefish_glyphs.fish b/functions/__bobthefish_glyphs.fish index 6d82b66..6513368 100644 --- a/functions/__bobthefish_glyphs.fish +++ b/functions/__bobthefish_glyphs.fish @@ -21,6 +21,7 @@ function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish' set -x ruby_glyph '' set -x go_glyph '' + set -x nix_glyph '' # Desk glyphs set -x desk_glyph \u25F2 @@ -62,6 +63,7 @@ function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish' set detached_glyph \uF417 set tag_glyph \uF412 + set nix_glyph \uF313 ' ' # nf-linux-nixos set virtualenv_glyph \uE73C ' ' set ruby_glyph \uE791 ' ' set go_glyph \uE626 ' ' From e24516b39bb62183ab7d70a8395d78ebb58f081f Mon Sep 17 00:00:00 2001 From: Duke Jones Date: Thu, 20 Jun 2019 10:12:36 +0200 Subject: [PATCH 16/18] Add theme_display_nix variable to other places. --- README.md | 1 + fish_prompt.fish | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 9893a1f..776d104 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ set -g theme_display_docker_machine no set -g theme_display_k8s_context yes set -g theme_display_hg yes set -g theme_display_virtualenv no +set -g theme_display_nix no set -g theme_display_ruby no set -g theme_display_nvm yes set -g theme_display_user ssh diff --git a/fish_prompt.fish b/fish_prompt.fish index dd209a0..504ed2c 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -31,6 +31,7 @@ # set -g theme_display_k8s_namespace no # set -g theme_display_hg yes # set -g theme_display_virtualenv no +# set -g theme_display_nix no # set -g theme_display_ruby no # set -g theme_display_user ssh # set -g theme_display_hostname ssh From 870ab7c9beffc791285dc7aa0e87b2e10ffb6b42 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 2 May 2020 09:19:56 -0700 Subject: [PATCH 17/18] Fix some edge cases when nerd fonts are on and powerline fonts are explicitly disabled. --- fish_prompt.fish | 2 +- fish_right_prompt.fish | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 504ed2c..6ce9052 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -393,7 +393,7 @@ function __bobthefish_finish_segments -S -d 'Close open prompt segments' if set -q theme_newline_prompt echo -ens "$theme_newline_prompt" - else if [ "$theme_powerline_fonts" = "no" ] + else if [ "$theme_powerline_fonts" = "no" -a "$theme_nerd_fonts" != "yes" ] echo -ns '> ' else echo -ns "$right_arrow_glyph " diff --git a/fish_right_prompt.fish b/fish_right_prompt.fish index c9e2c7a..bd6ee94 100644 --- a/fish_right_prompt.fish +++ b/fish_right_prompt.fish @@ -68,7 +68,7 @@ end function fish_right_prompt -d 'bobthefish is all about the right prompt' set -l __bobthefish_left_arrow_glyph \uE0B3 - if [ "$theme_powerline_fonts" = "no" ] + if [ "$theme_powerline_fonts" = "no" -a "$theme_nerd_fonts" != "yes" ] set __bobthefish_left_arrow_glyph '<' end From a2ad38aa051aaed25ae3bd6129986e7f27d42d7b Mon Sep 17 00:00:00 2001 From: Thibault Lacroux Date: Mon, 4 May 2020 15:48:01 +0200 Subject: [PATCH 18/18] Do not display Kubernetes context and namespace if it's the defaults ones --- fish_prompt.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fish_prompt.fish b/fish_prompt.fish index 6ce9052..4c47f7f 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -625,6 +625,10 @@ function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context' [ "$theme_display_k8s_namespace" = 'yes' ] and set -l namespace (__bobthefish_k8s_namespace) + [ -z $context -o "$context" = 'default' ] + and [ -z $namespace -o "$namespace" = 'default' ] + and return + set -l segment $k8s_glyph " " $context [ -n "$namespace" ] and set segment $segment ":" $namespace