Skip to content

Commit

Permalink
Add a rustc version segment with multiple install options
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Nov 30, 2021
1 parent 332f23a commit 51908d7
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -124,6 +125,7 @@ set -g theme_newline_prompt '$ '
**Prompt options**

- `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_rustc`. Use `no` to completely hide all information about Rustc version. Use `yes` to always show it. Use `cargo` to show the rustc version when inside a Cargo project. By default the Rustc version is displayed if there is a difference from global rustc installed (if any).
- `theme_display_node`. If set to `yes`, will display current NVM or FNM node version.
- `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.
Expand Down
15 changes: 15 additions & 0 deletions functions/__bobthefish_colors.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion functions/__bobthefish_glyphs.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ' '

Expand Down
4 changes: 4 additions & 0 deletions functions/bobthefish_display_colors.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions functions/fish_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -846,6 +847,37 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information'
echo -ns $ruby_glyph $ruby_version ' '
end

function __bobthefish_prompt_rustc -S -d 'Display current cargo version if different than system'
[ "$theme_display_rustc" = 'no' -o () ]
and return

type -fq rustc
or return

set -l local_rustc_version (command rustc --version | cut -d ' ' -f 2)
set -l should_show ''

switch "$theme_display_rustc"
case yes
set should_show 1
case cargo
cargo locate-project --message-format plain --quiet >/dev/null 2>/dev/null
and set should_show 1
case '*'
set -l global_rustc_version (pushd /; command rustc --version | cut -d ' ' -f 2; popd)
if [ "$local_rustc_version" != "$global_rustc_version" ]
set should_show 1
end
end

[ -z "$should_show" ]
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*'
Expand Down Expand Up @@ -1137,6 +1169,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
Expand Down

0 comments on commit 51908d7

Please sign in to comment.