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

@@ -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)