diff --git a/README.md b/README.md index ddd26f1..fdbd88d 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ 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_rustc no set -g theme_display_node yes set -g theme_display_user ssh set -g theme_display_hostname ssh @@ -125,6 +126,7 @@ set -g theme_newline_prompt '$ ' - `theme_display_ruby`. Use `no` to completely hide all information about Ruby version. By default Ruby version displayed if there is the difference from default settings. - `theme_display_node`. If set to `always`, will display current NPM, NVM or FNM node version. If set to `yes`, will display the version if an `.nvmrc`, `.node-version` or `package.json` file is found in the parent directories. +- `theme_display_rustc`. Use `no` to completely hide all information about the Rust compiler version. By default the Rust compiler version will be displayed if there is a difference from the globally installed one. - `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`). diff --git a/functions/__bobthefish_colors.fish b/functions/__bobthefish_colors.fish index b8b454f..bdf4b10 100644 --- a/functions/__bobthefish_colors.fish +++ b/functions/__bobthefish_colors.fish @@ -38,6 +38,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo brblue $colorfg --bold set -x color_desk brblue $colorfg --bold set -x color_nix brblue $colorfg --bold + set -x color_rustc brred $colorfg --bold case 'terminal-light*' set -l colorfg white @@ -73,6 +74,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo brblue $colorfg --bold set -x color_desk brblue $colorfg --bold set -x color_nix brblue $colorfg --bold + set -x color_rustc brred $colorfg --bold case 'terminal2' 'terminal2-dark*' set -l colorfg black @@ -108,6 +110,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo brblue $colorfg --bold set -x color_desk brblue $colorfg --bold set -x color_nix brblue $colorfg --bold + set -x color_rustc brred $colorfg --bold case 'terminal2-light*' set -l colorfg white @@ -143,6 +146,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo brblue $colorfg --bold set -x color_desk brblue $colorfg --bold set -x color_nix brblue $colorfg --bold + set -x color_rustc brred $colorfg --bold case 'zenburn' set -l grey 333333 # a bit darker than normal zenburn grey @@ -184,6 +188,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo $blue $grey --bold set -x color_desk $blue $grey --bold set -x color_nix $blue $grey --bold + set -x color_rustc $red $white --bold case 'base16-light' set -l base00 181818 @@ -236,6 +241,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo $base0D $colorfg --bold set -x color_desk $base0D $colorfg --bold set -x color_nix $base0D $colorfg --bold + set -x color_rustc $base08 $colorfg --bold case 'base16' 'base16-dark' set -l base00 181818 @@ -288,6 +294,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo $base0D $colorfg --bold set -x color_desk $base0D $colorfg --bold set -x color_nix $base0D $colorfg --bold + set -x color_rustc $base08 $colorfg --bold case 'solarized-light' set -l base03 002b36 @@ -340,6 +347,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo $cyan $colorfg --bold set -x color_desk $cyan $colorfg --bold set -x color_nix $cyan $colorfg --bold + set -x color_rustc $red $colorfg --bold case 'solarized' 'solarized-dark' set -l base03 002b36 @@ -392,6 +400,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo $cyan $colorfg --bold set -x color_desk $cyan $colorfg --bold set -x color_nix $cyan $colorfg --bold + set -x color_rustc $red $colorfg --bold case 'light' # light medium dark @@ -437,6 +446,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 + set -x color_rustc $ruby_red $grey[1] --bold case 'gruvbox' # light medium dark darkest @@ -481,6 +491,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 + set -x color_rustc $red[2] $fg[2] --bold case 'dracula' # https://draculatheme.com set -l bg 282a36 @@ -527,6 +538,7 @@ 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 set -x color_nix $cyan $bg --bold + set -x color_rustc $red $bg --bold case 'nord' set -l base00 2E3440 @@ -624,6 +636,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 + set -x color_rustc $ruby_red $white --bold end end @@ -651,6 +664,7 @@ function __bobthefish_user_color_scheme_deprecated 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 -q __color_rustc; or set -l __color_rustc af0000 cccccc --bold set_color black -b red --bold echo "The 'user' color scheme is deprecated." @@ -691,6 +705,7 @@ function __bobthefish_user_color_scheme_deprecated set -x color_virtualgo $__color_virtualgo set -x color_desk $__color_desk set -x color_nix $__color_nix + set -x color_rustc $__color_rustc end" echo diff --git a/functions/__bobthefish_glyphs.fish b/functions/__bobthefish_glyphs.fish index c0f13e2..e556aef 100644 --- a/functions/__bobthefish_glyphs.fish +++ b/functions/__bobthefish_glyphs.fish @@ -21,10 +21,11 @@ function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish' set -x pypy_glyph \u1D56 set -x ruby_glyph '' + set -x rustc_glyph '' set -x go_glyph '' set -x nix_glyph '' - # Desk glyphs + # Desk glyphs set -x desk_glyph \u25F2 # Kubernetes glyphs @@ -70,6 +71,7 @@ function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish' set nix_glyph \uF313 ' ' # nf-linux-nixos set virtualenv_glyph \uE73C ' ' set ruby_glyph \uE791 ' ' + set rustc_glyph \uE7a8 ' ' # Rust Nerd Font logo set go_glyph \uE626 ' ' set node_glyph \uE718 ' ' diff --git a/functions/bobthefish_display_colors.fish b/functions/bobthefish_display_colors.fish index 9719b27..cd426bb 100644 --- a/functions/bobthefish_display_colors.fish +++ b/functions/bobthefish_display_colors.fish @@ -129,6 +129,10 @@ function bobthefish_display_colors -a color_scheme -d 'Print example prompt colo echo -ns $ruby_glyph rvm ' ' __bobthefish_finish_segments + __bobthefish_start_segment $color_rust + echo -ns $rust_glyph rust ' ' + __bobthefish_finish_segments + __bobthefish_start_segment $color_virtualfish echo -ns $virtualenv_glyph virtualfish ' ' __bobthefish_finish_segments diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 1ec90fd..d568ef1 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -35,6 +35,7 @@ # set -g theme_display_virtualenv no # set -g theme_display_nix no # set -g theme_display_ruby no +# set -g theme_display_rustc no # set -g theme_display_user ssh # set -g theme_display_hostname ssh # set -g theme_display_sudo_user yes @@ -848,6 +849,46 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' echo -ns $ruby_glyph $ruby_version ' ' end +function __bobthefish_get_global_rustc_version -S -d 'Display the global cargo version' + command fish -c "cd /; rustc --version | cut -d ' ' -f 2" +end + +function __bobthefish_get_local_rustc_version -S -d 'Display the local cargo version in the CWD' + rustc --version | cut -d ' ' -f 2 +end + +function __bobthefish_prompt_rustc -S -d 'Display current cargo version if different than system' + [ "$theme_display_rustc" = 'no' ] + and return + + type -fq rustc + or return + + # If this value is non-zero we should show it as a segment. + set -l local_rustc_version + + switch "$theme_display_rustc" + case always + set local_rustc_version (__bobthefish_get_local_rustc_version) + case yes + if not set -q __bobthefish_global_rustc_version + set -g __bobthefish_global_rustc_version (__bobthefish_get_global_rustc_version) + end + + set local_rustc_version (__bobthefish_get_local_rustc_version) + if [ "$local_rustc_version" = "$__bobthefish_global_rustc_version" ] + set local_rustc_version '' + end + end + + [ -z "$local_rustc_version" ] + and return + + __bobthefish_start_segment $color_rustc + echo -ns $rustc_glyph $local_rustc_version ' ' + set_color normal +end + function __bobthefish_virtualenv_python_version -S -d 'Get current Python version' switch (python --version 2>&1 | tr '\n' ' ') case 'Python 2*PyPy*' @@ -1172,6 +1213,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' # Virtual environments __bobthefish_prompt_nix + __bobthefish_prompt_rustc __bobthefish_prompt_desk __bobthefish_prompt_rubies __bobthefish_prompt_virtualfish