diff --git a/README.md b/README.md index 8b8ad44..6268a1c 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ set -g theme_display_hg yes set -g theme_display_virtualenv no set -g theme_display_nix no set -g theme_display_ruby no -set -g theme_display_nvm yes +set -g theme_display_nodejs yes set -g theme_display_user ssh set -g theme_display_hostname ssh set -g theme_display_vi no @@ -124,7 +124,7 @@ set -g theme_newline_prompt '$ ' **Prompt options** - `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. -- `theme_display_nvm`. If set to `yes`, will display current NVM node version. +- `theme_display_nodejs`. If set to `yes`, will display current Node.js version. - `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. - `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. - `theme_display_k8s_context`. This feature is disabled by default. Use `yes` to show the current kubernetes context (`> kubectl config current-context`). diff --git a/fish_prompt.fish b/fish_prompt.fish index e0a653e..d38b9c1 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -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_nodejs yes # set -g theme_avoid_ambiguous_glyphs yes # set -g theme_powerline_fonts no # set -g theme_nerd_fonts yes @@ -895,14 +895,35 @@ 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_nodejs -S -d 'Display current Node.js version' + [ "$theme_display_nodejs" = 'yes' -o "$theme_display_nvm" = 'yes' ] or return - set -l node_version (nvm current 2> /dev/null) + set -l node_version + if type -q nvm + [ -n "$NVM_DIR" ] + or return - [ -z $node_version -o "$node_version" = 'none' -o "$node_version" = 'system' ] - and return + set node_version (nvm current 2> /dev/null) + + [ -z $node_version -o "$node_version" = 'none' -o "$node_version" = 'system' ] + and return + else if type -fq nodenv + set node_version (nodenv version-name) + + # Don't show global node version... + set -q NODENV_ROOT + or set -l NODENV_ROOT $HOME/.nodenv + + [ -e "$NODENV_ROOT/version" ] + and read -l global_node_version < "$NODENV_ROOT/version" + + [ "$global_node_version" ] + or set -l global_node_version system + + [ "$node_version" = "$global_node_version" ] + and return + end __bobthefish_start_segment $color_nvm echo -ns $node_glyph $node_version ' ' @@ -1124,7 +1145,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_nodejs set -l real_pwd (__bobthefish_pwd)