Skip to content

Commit 6f88208

Browse files
committed
Add support for nodenv
1 parent f3301c2 commit 6f88208

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

fish_prompt.fish

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -861,13 +861,31 @@ function __bobthefish_prompt_desk -S -d 'Display current desk environment'
861861
end
862862

863863
function __bobthefish_prompt_nvm -S -d 'Display current node version through NVM'
864-
[ "$theme_display_nvm" = 'yes' -a -n "$NVM_DIR" ]
865-
or return
864+
[ "$theme_display_nvm" = 'no' ]
865+
and return
866866

867-
set -l node_version (nvm current 2> /dev/null)
867+
set -l node_version
868+
if type -fq nvm
869+
set node_version (nvm current 2> /dev/null)
868870

869-
[ -z $node_version -o "$node_version" = 'none' -o "$node_version" = 'system' ]
870-
and return
871+
[ -z $node_version -o "$node_version" = 'none' -o "$node_version" = 'system' ]
872+
and return
873+
else if type -fq nodenv
874+
set node_version (nodenv version-name)
875+
876+
# Don't show global node version...
877+
set -q NODENV_ROOT
878+
or set -l NODENV_ROOT $HOME/.nodenv
879+
880+
[ -e "$NODENV_ROOT/version" ]
881+
and read -l global_node_version < "$NODENV_ROOT/version"
882+
883+
[ "$global_node_version" ]
884+
or set -l global_node_version system
885+
886+
[ "$node_version" = "$global_node_version" ]
887+
and return
888+
end
871889

872890
__bobthefish_start_segment $color_nvm
873891
echo -ns $node_glyph $node_version ' '

0 commit comments

Comments
 (0)