Skip to content

Commit 02c7be2

Browse files
committed
Add support for nodenv
This will make is so that the current Node.js version can be displayed using either nvm or nodenv. I also changed the configuration setting `theme_display_nvm` to `theme_display_nodejs`.
1 parent a2ad38a commit 02c7be2

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ set -g theme_display_hg yes
8484
set -g theme_display_virtualenv no
8585
set -g theme_display_nix no
8686
set -g theme_display_ruby no
87-
set -g theme_display_nvm yes
87+
set -g theme_display_nodejs yes
8888
set -g theme_display_user ssh
8989
set -g theme_display_hostname ssh
9090
set -g theme_display_vi no
@@ -119,7 +119,7 @@ set -g theme_newline_prompt '$ '
119119
**Prompt options**
120120

121121
- `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.
122-
- `theme_display_nvm`. If set to `yes`, will display current NVM node version.
122+
- `theme_display_nodejs`. If set to `yes`, will display current Node.js version.
123123
- `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.
124124
- `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.
125125
- `theme_display_k8s_context`. This feature is disabled by default. Use `yes` to show the current kubernetes context (`> kubectl config current-context`).

fish_prompt.fish

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# set -g theme_display_hostname ssh
3838
# set -g theme_display_sudo_user yes
3939
# set -g theme_display_vi no
40-
# set -g theme_display_nvm yes
40+
# set -g theme_display_nodejs yes
4141
# set -g theme_avoid_ambiguous_glyphs yes
4242
# set -g theme_powerline_fonts no
4343
# set -g theme_nerd_fonts yes
@@ -850,14 +850,35 @@ function __bobthefish_prompt_desk -S -d 'Display current desk environment'
850850
set_color normal
851851
end
852852

853-
function __bobthefish_prompt_nvm -S -d 'Display current node version through NVM'
854-
[ "$theme_display_nvm" = 'yes' -a -n "$NVM_DIR" ]
853+
function __bobthefish_prompt_nodejs -S -d 'Display current Node.js version'
854+
[ "$theme_display_nodejs" = 'yes' -o "$theme_display_nvm" = 'yes' ]
855855
or return
856856

857-
set -l node_version (nvm current 2> /dev/null)
857+
set -l node_version
858+
if type -q nvm
859+
[ -n "$NVM_DIR" ]
860+
or return
858861

859-
[ -z $node_version -o "$node_version" = 'none' -o "$node_version" = 'system' ]
860-
and return
862+
set node_version (nvm current 2> /dev/null)
863+
864+
[ -z $node_version -o "$node_version" = 'none' -o "$node_version" = 'system' ]
865+
and return
866+
else if type -fq nodenv
867+
set node_version (nodenv version-name)
868+
869+
# Don't show global node version...
870+
set -q NODENV_ROOT
871+
or set -l NODENV_ROOT $HOME/.nodenv
872+
873+
[ -e "$NODENV_ROOT/version" ]
874+
and read -l global_node_version < "$NODENV_ROOT/version"
875+
876+
[ "$global_node_version" ]
877+
or set -l global_node_version system
878+
879+
[ "$node_version" = "$global_node_version" ]
880+
and return
881+
end
861882

862883
__bobthefish_start_segment $color_nvm
863884
echo -ns $node_glyph $node_version ' '
@@ -1076,7 +1097,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
10761097
__bobthefish_prompt_rubies
10771098
__bobthefish_prompt_virtualfish
10781099
__bobthefish_prompt_virtualgo
1079-
__bobthefish_prompt_nvm
1100+
__bobthefish_prompt_nodejs
10801101

10811102
set -l real_pwd (__bobthefish_pwd)
10821103

0 commit comments

Comments
 (0)