Skip to content

Commit 67ae446

Browse files
Add NVM prompt
1 parent 3b2e847 commit 67ae446

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ This theme is based loosely on [agnoster][agnoster].
4747
* Current RVM, rbenv or chruby (Ruby) version
4848
* Current virtualenv (Python) version
4949
* _If you use virtualenv, you will probably need to disable the default virtualenv prompt, since it doesn't play nice with fish: `set -x VIRTUAL_ENV_DISABLE_PROMPT 1`_
50+
* Current NVM version (Nodejs) (inactive by default; see configurations in the next paragraph)
5051
* Abbreviated parent directory
5152
* Current directory, or Git or Mercurial project name
5253
* Current project's repo branch (<img width="16" alt="branch-glyph" src="https://cloud.githubusercontent.com/assets/53660/8768360/53ee9b58-2e32-11e5-9977-cee0063936fa.png"> master) or detached head (`` d0dfd9b)
@@ -81,6 +82,7 @@ set -g theme_display_k8s_context yes
8182
set -g theme_display_hg yes
8283
set -g theme_display_virtualenv no
8384
set -g theme_display_ruby no
85+
set -g theme_display_nvm yes
8486
set -g theme_display_user ssh
8587
set -g theme_display_hostname ssh
8688
set -g theme_display_vi no
@@ -113,6 +115,7 @@ set -g theme_newline_prompt '$ '
113115
**Prompt options**
114116

115117
- `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.
118+
- `theme_display_nvm`. If set to `yes`, will display current NVM node version.
116119
- `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.
117120
- `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.
118121
- `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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
# set -g theme_display_user ssh
3535
# set -g theme_display_hostname ssh
3636
# set -g theme_display_vi no
37+
# set -g theme_display_nvm yes
3738
# set -g theme_avoid_ambiguous_glyphs yes
3839
# set -g theme_powerline_fonts no
3940
# set -g theme_nerd_fonts yes
@@ -801,6 +802,20 @@ function __bobthefish_prompt_desk -S -d 'Display current desk environment'
801802
set_color normal
802803
end
803804

805+
function __bobthefish_prompt_nvm -S -d 'Display current node version through NVM'
806+
[ "$theme_display_nvm" = 'yes' -a -n "$NVM_DIR" ]
807+
or return
808+
809+
set -l node_version (nvm current 2> /dev/null)
810+
811+
[ -z $node_version -o "$node_version" = 'none' ]
812+
and return
813+
814+
__bobthefish_start_segment $color_nvm
815+
echo -ns $node_glyph $node_version ' '
816+
set_color normal
817+
end
818+
804819

805820
# ==============================
806821
# VCS segments
@@ -1004,6 +1019,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
10041019
__bobthefish_prompt_rubies
10051020
__bobthefish_prompt_virtualfish
10061021
__bobthefish_prompt_virtualgo
1022+
__bobthefish_prompt_nvm
10071023

10081024
set -l real_pwd (__bobthefish_pwd)
10091025

functions/__bobthefish_colors.fish

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
3030
set -x color_username white black --bold
3131
set -x color_hostname white black
3232
set -x color_rvm brmagenta $colorfg --bold
33+
set -x color_nvm brgreen $colorfg --bold
3334
set -x color_virtualfish brblue $colorfg --bold
3435
set -x color_virtualgo brblue $colorfg --bold
3536
set -x color_desk brblue $colorfg --bold
@@ -60,6 +61,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
6061
set -x color_username black white --bold
6162
set -x color_hostname black white
6263
set -x color_rvm brmagenta $colorfg --bold
64+
set -x color_nvm brgreen $colorfg --bold
6365
set -x color_virtualfish brblue $colorfg --bold
6466
set -x color_virtualgo brblue $colorfg --bold
6567
set -x color_desk brblue $colorfg --bold
@@ -90,6 +92,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
9092
set -x color_username brgrey white --bold
9193
set -x color_hostname brgrey white
9294
set -x color_rvm brmagenta $colorfg --bold
95+
set -x color_nvm brgreen $colorfg --bold
9396
set -x color_virtualfish brblue $colorfg --bold
9497
set -x color_virtualgo brblue $colorfg --bold
9598
set -x color_desk brblue $colorfg --bold
@@ -120,6 +123,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
120123
set -x color_username grey black --bold
121124
set -x color_hostname grey black
122125
set -x color_rvm brmagenta $colorfg --bold
126+
set -x color_nvm brgreen $colorfg --bold
123127
set -x color_virtualfish brblue $colorfg --bold
124128
set -x color_virtualgo brblue $colorfg --bold
125129
set -x color_desk brblue $colorfg --bold
@@ -156,6 +160,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
156160
set -x color_username $grey $blue --bold
157161
set -x color_hostname $grey $blue
158162
set -x color_rvm $red $grey --bold
163+
set -x color_nvm $green $white --bold
159164
set -x color_virtualfish $blue $grey --bold
160165
set -x color_virtualgo $blue $grey --bold
161166
set -x color_desk $blue $grey --bold
@@ -203,6 +208,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
203208
set -x color_username $base02 $base0D --bold
204209
set -x color_hostname $base02 $base0D
205210
set -x color_rvm $base08 $colorfg --bold
211+
set -x color_nvm $base0B $colorfg --bold
206212
set -x color_virtualfish $base0D $colorfg --bold
207213
set -x color_virtualgo $base0D $colorfg --bold
208214
set -x color_desk $base0D $colorfg --bold
@@ -250,6 +256,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
250256
set -x color_username $base02 $base0D --bold
251257
set -x color_hostname $base02 $base0D
252258
set -x color_rvm $base08 $colorfg --bold
259+
set -x color_nvm $base0B $colorfg --bold
253260
set -x color_virtualfish $base0D $colorfg --bold
254261
set -x color_virtualgo $base0D $colorfg --bold
255262
set -x color_desk $base0D $colorfg --bold
@@ -297,6 +304,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
297304
set -x color_username $base2 $blue --bold
298305
set -x color_hostname $base2 $blue
299306
set -x color_rvm $red $colorfg --bold
307+
set -x color_nvm $green $colorfg --bold
300308
set -x color_virtualfish $cyan $colorfg --bold
301309
set -x color_virtualgo $cyan $colorfg --bold
302310
set -x color_desk $cyan $colorfg --bold
@@ -344,6 +352,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
344352
set -x color_username $base02 $blue --bold
345353
set -x color_hostname $base02 $blue
346354
set -x color_rvm $red $colorfg --bold
355+
set -x color_nvm $green $colorfg --bold
347356
set -x color_virtualfish $cyan $colorfg --bold
348357
set -x color_virtualgo $cyan $colorfg --bold
349358
set -x color_desk $cyan $colorfg --bold
@@ -384,6 +393,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
384393
set -x color_username $grey[1] $blue[3] --bold
385394
set -x color_hostname $grey[1] $blue[3]
386395
set -x color_rvm $ruby_red $grey[1] --bold
396+
set -x color_nvm $green $grey[1] --bold
387397
set -x color_virtualfish $blue[2] $grey[1] --bold
388398
set -x color_virtualgo $blue[2] $grey[1] --bold
389399
set -x color_desk $blue[2] $grey[1] --bold
@@ -423,6 +433,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
423433
set -x color_username $fg[3] $blue[2] --bold
424434
set -x color_hostname $fg[3] $blue[2]
425435
set -x color_rvm $red[2] $fg[2] --bold
436+
set -x color_nvm $green[1] $fg[2] --bold
426437
set -x color_virtualfish $blue[2] $fg[2] --bold
427438
set -x color_virtualgo $blue[2] $fg[2] --bold
428439
set -x color_desk $blue[2] $fg[2] --bold
@@ -464,6 +475,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
464475
set -x color_username $selection $cyan --bold
465476
set -x color_hostname $selection $cyan
466477
set -x color_rvm $red $bg --bold
478+
set -x color_nvm $green $bg --bold
467479
set -x color_virtualfish $comment $bg --bold
468480
set -x color_virtualgo $cyan $bg --bold
469481
set -x color_desk $comment $bg --bold
@@ -505,6 +517,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe
505517
set -x color_username $grey[1] $blue[3] --bold
506518
set -x color_hostname $grey[1] $blue[3]
507519
set -x color_rvm $ruby_red $grey[1] --bold
520+
set -x color_nvm $green[1] $white --bold
508521
set -x color_virtualfish $blue[2] $grey[1] --bold
509522
set -x color_virtualgo $go_blue $black --bold
510523
set -x color_desk $blue[2] $grey[1] --bold

functions/__bobthefish_glyphs.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish'
6262
set virtualenv_glyph \uE73C ' '
6363
set ruby_glyph \uE791 ' '
6464
set go_glyph \uE626 ' '
65+
set node_glyph \uF898 ' '
6566

6667
set vagrant_running_glyph \uF431 # ↑ 'running'
6768
set vagrant_poweroff_glyph \uF433 # ↓ 'poweroff'

0 commit comments

Comments
 (0)