|
37 | 37 | # set -g theme_display_hostname ssh |
38 | 38 | # set -g theme_display_sudo_user yes |
39 | 39 | # set -g theme_display_vi no |
40 | | -# set -g theme_display_nvm yes |
| 40 | +# set -g theme_display_nodejs yes |
41 | 41 | # set -g theme_avoid_ambiguous_glyphs yes |
42 | 42 | # set -g theme_powerline_fonts no |
43 | 43 | # set -g theme_nerd_fonts yes |
@@ -850,14 +850,35 @@ function __bobthefish_prompt_desk -S -d 'Display current desk environment' |
850 | 850 | set_color normal |
851 | 851 | end |
852 | 852 |
|
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' ] |
855 | 855 | or return |
856 | 856 |
|
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 |
858 | 861 |
|
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 |
861 | 882 |
|
862 | 883 | __bobthefish_start_segment $color_nvm |
863 | 884 | echo -ns $node_glyph $node_version ' ' |
@@ -1076,7 +1097,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' |
1076 | 1097 | __bobthefish_prompt_rubies |
1077 | 1098 | __bobthefish_prompt_virtualfish |
1078 | 1099 | __bobthefish_prompt_virtualgo |
1079 | | - __bobthefish_prompt_nvm |
| 1100 | + __bobthefish_prompt_nodejs |
1080 | 1101 |
|
1081 | 1102 | set -l real_pwd (__bobthefish_pwd) |
1082 | 1103 |
|
|
0 commit comments