Add FNM as an alternative to NVM (#292)

* Add FNM as an alternative to NVM
* Made the __bobthefish_prompt_nvm generic for nvm and fnm
* Hide errors on node_manager current
* Check for color_nvm and set color_node based on that
This commit is contained in:
Wes Baker
2021-01-24 17:14:30 -05:00
committed by GitHub
parent 954fbc961b
commit af5aac28c4
3 changed files with 40 additions and 23 deletions

View File

@@ -33,7 +33,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username white black --bold
set -x color_hostname white black
set -x color_rvm brmagenta $colorfg --bold
set -x color_nvm brgreen $colorfg --bold
set -x color_node brgreen $colorfg --bold
set -x color_virtualfish brblue $colorfg --bold
set -x color_virtualgo brblue $colorfg --bold
set -x color_desk brblue $colorfg --bold
@@ -68,7 +68,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username black white --bold
set -x color_hostname black white
set -x color_rvm brmagenta $colorfg --bold
set -x color_nvm brgreen $colorfg --bold
set -x color_node brgreen $colorfg --bold
set -x color_virtualfish brblue $colorfg --bold
set -x color_virtualgo brblue $colorfg --bold
set -x color_desk brblue $colorfg --bold
@@ -103,7 +103,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username brgrey white --bold
set -x color_hostname brgrey white
set -x color_rvm brmagenta $colorfg --bold
set -x color_nvm brgreen $colorfg --bold
set -x color_node brgreen $colorfg --bold
set -x color_virtualfish brblue $colorfg --bold
set -x color_virtualgo brblue $colorfg --bold
set -x color_desk brblue $colorfg --bold
@@ -138,7 +138,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username grey black --bold
set -x color_hostname grey black
set -x color_rvm brmagenta $colorfg --bold
set -x color_nvm brgreen $colorfg --bold
set -x color_node brgreen $colorfg --bold
set -x color_virtualfish brblue $colorfg --bold
set -x color_virtualgo brblue $colorfg --bold
set -x color_desk brblue $colorfg --bold
@@ -179,7 +179,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username $grey $blue --bold
set -x color_hostname $grey $blue
set -x color_rvm $red $grey --bold
set -x color_nvm $green $white --bold
set -x color_node $green $white --bold
set -x color_virtualfish $blue $grey --bold
set -x color_virtualgo $blue $grey --bold
set -x color_desk $blue $grey --bold
@@ -231,7 +231,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username $base02 $base0D --bold
set -x color_hostname $base02 $base0D
set -x color_rvm $base08 $colorfg --bold
set -x color_nvm $base0B $colorfg --bold
set -x color_node $base0B $colorfg --bold
set -x color_virtualfish $base0D $colorfg --bold
set -x color_virtualgo $base0D $colorfg --bold
set -x color_desk $base0D $colorfg --bold
@@ -283,7 +283,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username $base02 $base0D --bold
set -x color_hostname $base02 $base0D
set -x color_rvm $base08 $colorfg --bold
set -x color_nvm $base0B $colorfg --bold
set -x color_node $base0B $colorfg --bold
set -x color_virtualfish $base0D $colorfg --bold
set -x color_virtualgo $base0D $colorfg --bold
set -x color_desk $base0D $colorfg --bold
@@ -335,7 +335,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username $base2 $blue --bold
set -x color_hostname $base2 $blue
set -x color_rvm $red $colorfg --bold
set -x color_nvm $green $colorfg --bold
set -x color_node $green $colorfg --bold
set -x color_virtualfish $cyan $colorfg --bold
set -x color_virtualgo $cyan $colorfg --bold
set -x color_desk $cyan $colorfg --bold
@@ -387,7 +387,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username $base02 $blue --bold
set -x color_hostname $base02 $blue
set -x color_rvm $red $colorfg --bold
set -x color_nvm $green $colorfg --bold
set -x color_node $green $colorfg --bold
set -x color_virtualfish $cyan $colorfg --bold
set -x color_virtualgo $cyan $colorfg --bold
set -x color_desk $cyan $colorfg --bold
@@ -432,7 +432,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username $grey[1] $blue[3] --bold
set -x color_hostname $grey[1] $blue[3]
set -x color_rvm $ruby_red $grey[1] --bold
set -x color_nvm $green $grey[1] --bold
set -x color_node $green $grey[1] --bold
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
@@ -476,7 +476,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username $fg[3] $blue[2] --bold
set -x color_hostname $fg[3] $blue[2]
set -x color_rvm $red[2] $fg[2] --bold
set -x color_nvm $green[1] $fg[2] --bold
set -x color_node $green[1] $fg[2] --bold
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
@@ -522,7 +522,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username $selection $cyan --bold
set -x color_hostname $selection $cyan
set -x color_rvm $red $bg --bold
set -x color_nvm $green $bg --bold
set -x color_node $green $bg --bold
set -x color_virtualfish $comment $bg --bold
set -x color_virtualgo $cyan $bg --bold
set -x color_desk $comment $bg --bold
@@ -574,7 +574,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username $base02 $base0D --bold
set -x color_hostname $base02 $base0D
set -x color_rvm $base09 $colorfg --bold
set -x color_nvm $base09 $colorfg --bold
set -x color_node $base09 $colorfg --bold
set -x color_virtualfish $base09 $colorfg --bold
set -x color_virtualgo $base09 $colorfg --bold
set -x color_desk $base09 $colorfg --bold
@@ -619,7 +619,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
set -x color_username $grey[1] $blue[3] --bold
set -x color_hostname $grey[1] $blue[3]
set -x color_rvm $ruby_red $grey[1] --bold
set -x color_nvm $green[1] $white --bold
set -x color_node $green[1] $white --bold
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

View File

@@ -39,7 +39,7 @@
# set -g theme_display_hostname ssh
# set -g theme_display_sudo_user yes
# set -g theme_display_vi no
# set -g theme_display_nvm yes
# set -g theme_display_node yes
# set -g theme_avoid_ambiguous_glyphs yes
# set -g theme_powerline_fonts no
# set -g theme_nerd_fonts yes
@@ -895,16 +895,33 @@ function __bobthefish_prompt_desk -S -d 'Display current desk environment'
set_color normal
end
function __bobthefish_prompt_nvm -S -d 'Display current node version through NVM'
[ "$theme_display_nvm" = 'yes' -a -n "$NVM_DIR" ]
function __bobthefish_prompt_node -S -d 'Display current node version'
[ "$theme_display_node" = "yes" -o "$theme_display_nvm" = 'yes' ]
or return
set -l node_version (nvm current 2> /dev/null)
set -l node_manager
set -l node_manager_dir
if type -fq nvm
set node_manager "nvm"
set node_manager_dir $NVM_DIR
else if type -fq fnm
set node_manager "fnm"
set node_manager_dir $FNM_DIR
end
[ -n "$node_manager_dir" ]
or return
set -l node_version ("$node_manager" current 2> /dev/null)
[ -z $node_version -o "$node_version" = 'none' -o "$node_version" = 'system' ]
and return
__bobthefish_start_segment $color_nvm
[ -n "$color_nvm" ]
and set -x color_node $color_nvm
__bobthefish_start_segment $color_node
echo -ns $node_glyph $node_version ' '
set_color normal
end
@@ -1124,7 +1141,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
__bobthefish_prompt_rubies
__bobthefish_prompt_virtualfish
__bobthefish_prompt_virtualgo
__bobthefish_prompt_nvm
__bobthefish_prompt_node
set -l real_pwd (__bobthefish_pwd)