From 34a18148a9b8f48a701bdf61907c24aebb21d235 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Tue, 8 Feb 2022 21:34:58 -0800 Subject: [PATCH] Address first pass of comments --- README.md | 2 +- functions/__bobthefish_glyphs.fish | 4 ++-- functions/fish_prompt.fish | 25 ++++++++++++------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bc4ee54..fdbd88d 100644 --- a/README.md +++ b/README.md @@ -126,7 +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`. If set to `always`, will always show the rustc version. If set to `yes`, will show the version when inside a Cargo project. Use `diff` to show the rustc version if there is a difference from global rustc installed (if any). By default, we do not show the information. +- `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_glyphs.fish b/functions/__bobthefish_glyphs.fish index a280fa9..e556aef 100644 --- a/functions/__bobthefish_glyphs.fish +++ b/functions/__bobthefish_glyphs.fish @@ -21,7 +21,7 @@ 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 rustc_glyph '' set -x go_glyph '' set -x nix_glyph '' @@ -71,7 +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 rustc_glyph \uE7a8 ' ' # Rust Nerd Font logo set go_glyph \uE626 ' ' set node_glyph \uE718 ' ' diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 33c3abd..b6c8ccb 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -847,14 +847,16 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' echo -ns $ruby_glyph $ruby_version ' ' end -function __bobthefish_get_cargo_version -S -d 'Display the cargo version in a directory' - pushd $argv[1] - command rustc --version | cut -d ' ' -f 2 - popd +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" = '' ] + [ "$theme_display_rustc" = 'no' ] and return type -fq rustc @@ -865,17 +867,14 @@ function __bobthefish_prompt_rustc -S -d 'Display current cargo version if diffe switch "$theme_display_rustc" case always - set local_rustc_version (__bobthefish_get_cargo_version (__bobthefish_pwd)) + set local_rustc_version (__bobthefish_get_local_rustc_version) case yes - cargo locate-project --message-format plain --quiet >/dev/null 2>/dev/null - and set local_rustc_version (__bobthefish_get_cargo_version (__bobthefish_pwd)) - case diff - if not set -q __bobthefish_global_cargo_version - set -g __bobthefish_global_cargo_version (__bobthefish_get_cargo_version /) + 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_cargo_version (__bobthefish_pwd)) - if [ "$local_rustc_version" = "$__bobthefish_global_cargo_version" ] + set local_rustc_version (__bobthefish_get_local_rustc_version) + if [ "$local_rustc_version" = "$__bobthefish_global_rustc_version" ] set local_rustc_version '' end end