From fa23a38efcaa75a75fc3f750420ad05a95b0947e Mon Sep 17 00:00:00 2001 From: Xolve Date: Sun, 6 Sep 2020 23:53:47 +0530 Subject: [PATCH] Add nvm display to prompt. --- functions/_tide_item_nvm.fish | 23 +++++++++++++++++++ tide_theme/configure/configs/classic.fish | 6 +++-- tide_theme/configure/configs/lean.fish | 6 +++-- tide_theme/configure/configs/pure.fish | 6 +++-- tide_theme/configure/configs/rainbow.fish | 6 +++-- .../prompt_items/_fake_tide_item_nvm.fish | 2 ++ 6 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 functions/_tide_item_nvm.fish create mode 100644 tide_theme/configure/prompt_items/_fake_tide_item_nvm.fish diff --git a/functions/_tide_item_nvm.fish b/functions/_tide_item_nvm.fish new file mode 100644 index 0000000..7788393 --- /dev/null +++ b/functions/_tide_item_nvm.fish @@ -0,0 +1,23 @@ +function _tide_node_version + function top_level_dir --argument-names dirPath + echo (string split --max 2 / $dirPath)[2] + end + + set -l node_path_begin (top_level_dir (which node 2>/dev/null)) + set -l home_path_begin (top_level_dir $HOME) + + if test $node_path_begin = $home_path_begin; + echo (node --version) + else; + echo "system" + end +end + +function _tide_item_nvm + set -l node_version (_tide_node_version) + + if test "$node_version" != "system" -a -n "$node_version" + set_color $tide_nvm_color + printf '%s ' "$tide_nvm_icon $node_version" + end +end diff --git a/tide_theme/configure/configs/classic.fish b/tide_theme/configure/configs/classic.fish index 3c755d0..b6aa56a 100644 --- a/tide_theme/configure/configs/classic.fish +++ b/tide_theme/configure/configs/classic.fish @@ -61,7 +61,7 @@ tide_right_prompt_frame_enabled true tide_right_prompt_item_separator_diff_color '' tide_right_prompt_item_separator_same_color '' tide_right_prompt_item_separator_same_color_color 949494 -tide_right_prompt_items 'status' 'cmd_duration' 'context' 'jobs' 'virtual_env' +tide_right_prompt_items 'status' 'cmd_duration' 'context' 'jobs' 'nvm' 'virtual_env' tide_right_prompt_pad_items true tide_right_prompt_prefix '' tide_right_prompt_suffix '' @@ -82,4 +82,6 @@ tide_time_format '%T' tide_virtual_env_bg_color 444444 tide_virtual_env_color 00AFAF tide_virtual_env_display_mode 'projectName' -tide_virtual_env_icon '' \ No newline at end of file +tide_virtual_env_icon '' +tide_nvm_color 00AFAF +tide_nvm_icon '' \ No newline at end of file diff --git a/tide_theme/configure/configs/lean.fish b/tide_theme/configure/configs/lean.fish index ae63d9f..14feb74 100644 --- a/tide_theme/configure/configs/lean.fish +++ b/tide_theme/configure/configs/lean.fish @@ -61,7 +61,7 @@ tide_right_prompt_frame_enabled false tide_right_prompt_item_separator_diff_color ' ' tide_right_prompt_item_separator_same_color ' ' tide_right_prompt_item_separator_same_color_color 949494 -tide_right_prompt_items 'status' 'cmd_duration' 'context' 'jobs' 'virtual_env' +tide_right_prompt_items 'status' 'cmd_duration' 'context' 'jobs' 'nvm' 'virtual_env' tide_right_prompt_pad_items false tide_right_prompt_prefix ' ' tide_right_prompt_suffix '' @@ -82,4 +82,6 @@ tide_time_format '%T' tide_virtual_env_bg_color normal tide_virtual_env_color 00AFAF tide_virtual_env_display_mode 'projectName' -tide_virtual_env_icon '' \ No newline at end of file +tide_virtual_env_icon '' +tide_nvm_color 00AFAF +tide_nvm_icon '' \ No newline at end of file diff --git a/tide_theme/configure/configs/pure.fish b/tide_theme/configure/configs/pure.fish index 57fe408..ac30fae 100644 --- a/tide_theme/configure/configs/pure.fish +++ b/tide_theme/configure/configs/pure.fish @@ -32,7 +32,7 @@ tide_left_prompt_frame_enabled false tide_left_prompt_item_separator_diff_color ' ' tide_left_prompt_item_separator_same_color ' ' tide_left_prompt_item_separator_same_color_color 949494 -tide_left_prompt_items 'pwd' 'git_prompt' 'cmd_duration' 'virtual_env' 'newline' 'prompt_char' +tide_left_prompt_items 'pwd' 'git_prompt' 'cmd_duration' 'nvm' 'virtual_env' 'newline' 'prompt_char' tide_left_prompt_pad_items false tide_left_prompt_prefix '' tide_left_prompt_suffix ' ' @@ -82,4 +82,6 @@ tide_time_format '%T' tide_virtual_env_bg_color normal tide_virtual_env_color 00AFAF tide_virtual_env_display_mode 'projectName' -tide_virtual_env_icon '' \ No newline at end of file +tide_virtual_env_icon '' +tide_nvm_color 00AFAF +tide_nvm_icon '' \ No newline at end of file diff --git a/tide_theme/configure/configs/rainbow.fish b/tide_theme/configure/configs/rainbow.fish index c688864..33e31d5 100644 --- a/tide_theme/configure/configs/rainbow.fish +++ b/tide_theme/configure/configs/rainbow.fish @@ -61,7 +61,7 @@ tide_right_prompt_frame_enabled true tide_right_prompt_item_separator_diff_color '' tide_right_prompt_item_separator_same_color '' tide_right_prompt_item_separator_same_color_color 949494 -tide_right_prompt_items 'status' 'cmd_duration' 'context' 'jobs' 'virtual_env' +tide_right_prompt_items 'status' 'cmd_duration' 'context' 'jobs' 'nvm' 'virtual_env' tide_right_prompt_pad_items true tide_right_prompt_prefix '' tide_right_prompt_suffix '' @@ -82,4 +82,6 @@ tide_time_format '%T' tide_virtual_env_bg_color 444444 tide_virtual_env_color 00AFAF tide_virtual_env_display_mode 'projectName' -tide_virtual_env_icon '' \ No newline at end of file +tide_virtual_env_icon '' +tide_nvm_color 00AFAF +tide_nvm_icon '' \ No newline at end of file diff --git a/tide_theme/configure/prompt_items/_fake_tide_item_nvm.fish b/tide_theme/configure/prompt_items/_fake_tide_item_nvm.fish new file mode 100644 index 0000000..e9ef022 --- /dev/null +++ b/tide_theme/configure/prompt_items/_fake_tide_item_nvm.fish @@ -0,0 +1,2 @@ +function _fake_tide_item_nvm +end