Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a rustc version segment with multiple install options #314

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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`).
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
42 changes: 42 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,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*'
Expand Down Expand Up @@ -1170,6 +1211,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