From 75238d14ee9f56c6b2bc4cc208a13031d13164e4 Mon Sep 17 00:00:00 2001 From: Yonatan Striem-Amit Date: Thu, 6 Jan 2022 07:59:37 -0500 Subject: [PATCH 1/3] java support for tide --- functions/_tide_item_java.fish | 3 +++ functions/_tide_remove_unusable_items.fish | 2 +- functions/tide/configure/configs/classic.fish | 5 ++++- functions/tide/configure/configs/classic_16color.fish | 2 ++ functions/tide/configure/configs/lean.fish | 5 ++++- functions/tide/configure/configs/lean_16color.fish | 2 ++ functions/tide/configure/configs/rainbow.fish | 5 ++++- functions/tide/configure/configs/rainbow_16color.fish | 2 ++ 8 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 functions/_tide_item_java.fish diff --git a/functions/_tide_item_java.fish b/functions/_tide_item_java.fish new file mode 100644 index 0000000..2bd577f --- /dev/null +++ b/functions/_tide_item_java.fish @@ -0,0 +1,3 @@ +function _tide_item_java + test -e pom.xml && _tide_print_item java $tide_java_icon' ' (set jv (java -version 2>&1 | head -1 | string split ' ')[3]; echo $jv | string trim -c '"') +end diff --git a/functions/_tide_remove_unusable_items.fish b/functions/_tide_remove_unusable_items.fish index d885cf4..8dac808 100644 --- a/functions/_tide_remove_unusable_items.fish +++ b/functions/_tide_remove_unusable_items.fish @@ -1,6 +1,6 @@ function _tide_remove_unusable_items # Remove tool-specific items for tools the machine doesn't have installed - for item in chruby git go kubectl node php rustc terraform virtual_env + for item in chruby git go kubectl node php rustc java terraform virtual_env set -l cli_names $item switch $item case virtual_env diff --git a/functions/tide/configure/configs/classic.fish b/functions/tide/configure/configs/classic.fish index fcbe1c4..dd547d8 100644 --- a/functions/tide/configure/configs/classic.fish +++ b/functions/tide/configure/configs/classic.fish @@ -67,7 +67,7 @@ tide_pwd_icon_home tide_pwd_icon_unwritable '' tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json tide_right_prompt_frame_enabled true -tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc php chruby go kubectl terraform vi_mode +tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php chruby go kubectl terraform vi_mode tide_right_prompt_prefix '' tide_right_prompt_separator_diff_color '' tide_right_prompt_separator_same_color '' @@ -75,6 +75,9 @@ tide_right_prompt_suffix '' tide_rustc_bg_color 444444 tide_rustc_color F74C00 tide_rustc_icon '' +tide_java_bg_color 444444 +tide_java_color F74C00 +tide_java_icon '' tide_shlvl_bg_color 444444 tide_shlvl_color d78700 tide_shlvl_icon '' diff --git a/functions/tide/configure/configs/classic_16color.fish b/functions/tide/configure/configs/classic_16color.fish index d3a505f..06f1b97 100644 --- a/functions/tide/configure/configs/classic_16color.fish +++ b/functions/tide/configure/configs/classic_16color.fish @@ -39,6 +39,8 @@ tide_pwd_color_dirs cyan tide_pwd_color_truncated_dirs magenta tide_rustc_bg_color black tide_rustc_color red +tide_java_bg_color black +tide_java_color red tide_shlvl_bg_color black tide_shlvl_color yellow tide_status_bg_color black diff --git a/functions/tide/configure/configs/lean.fish b/functions/tide/configure/configs/lean.fish index ba45973..88bcb2a 100644 --- a/functions/tide/configure/configs/lean.fish +++ b/functions/tide/configure/configs/lean.fish @@ -67,7 +67,7 @@ tide_pwd_icon_home tide_pwd_icon_unwritable '' tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json tide_right_prompt_frame_enabled false -tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc php chruby go kubectl terraform +tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php chruby go kubectl terraform tide_right_prompt_prefix ' ' tide_right_prompt_separator_diff_color ' ' tide_right_prompt_separator_same_color ' ' @@ -75,6 +75,9 @@ tide_right_prompt_suffix '' tide_rustc_bg_color normal tide_rustc_color F74C00 tide_rustc_icon '' +tide_java_bg_color normal +tide_java_color F74C00 +tide_java_icon '' tide_shlvl_bg_color normal tide_shlvl_color d78700 tide_shlvl_icon '' diff --git a/functions/tide/configure/configs/lean_16color.fish b/functions/tide/configure/configs/lean_16color.fish index ead6e6f..5209e1e 100644 --- a/functions/tide/configure/configs/lean_16color.fish +++ b/functions/tide/configure/configs/lean_16color.fish @@ -39,6 +39,8 @@ tide_pwd_color_dirs cyan tide_pwd_color_truncated_dirs magenta tide_rustc_bg_color normal tide_rustc_color red +tide_java_bg_color normal +tide_java_color red tide_shlvl_bg_color normal tide_shlvl_color yellow tide_status_bg_color normal diff --git a/functions/tide/configure/configs/rainbow.fish b/functions/tide/configure/configs/rainbow.fish index 39afcbc..1654d97 100644 --- a/functions/tide/configure/configs/rainbow.fish +++ b/functions/tide/configure/configs/rainbow.fish @@ -67,7 +67,7 @@ tide_pwd_icon_home tide_pwd_icon_unwritable '' tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json tide_right_prompt_frame_enabled true -tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc php chruby go kubectl terraform vi_mode +tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php chruby go kubectl terraform vi_mode tide_right_prompt_prefix '' tide_right_prompt_separator_diff_color '' tide_right_prompt_separator_same_color '' @@ -75,6 +75,9 @@ tide_right_prompt_suffix '' tide_rustc_bg_color F74C00 tide_rustc_color 000000 tide_rustc_icon '' +tide_java_bg_color F74C00 +tide_java_color 000000 +tide_java_icon '' tide_shlvl_bg_color 808000 tide_shlvl_color 000000 tide_shlvl_icon '' diff --git a/functions/tide/configure/configs/rainbow_16color.fish b/functions/tide/configure/configs/rainbow_16color.fish index c38b6c5..7b338e5 100644 --- a/functions/tide/configure/configs/rainbow_16color.fish +++ b/functions/tide/configure/configs/rainbow_16color.fish @@ -39,6 +39,8 @@ tide_pwd_color_dirs brwhite tide_pwd_color_truncated_dirs white tide_rustc_bg_color red tide_rustc_color black +tide_java_bg_color red +tide_java_color black tide_shlvl_bg_color yellow tide_shlvl_color black tide_status_bg_color black From a592d34abd51ad45c221ae3aa0cd13a8263484cd Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Thu, 6 Jan 2022 08:48:57 -0800 Subject: [PATCH 2/3] Fix colors, simplify item --- functions/_tide_item_java.fish | 2 +- functions/tide/configure/configs/classic.fish | 6 +++--- functions/tide/configure/configs/classic_16color.fish | 4 ++-- functions/tide/configure/configs/lean.fish | 6 +++--- functions/tide/configure/configs/lean_16color.fish | 4 ++-- functions/tide/configure/configs/rainbow.fish | 6 +++--- functions/tide/configure/configs/rainbow_16color.fish | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/functions/_tide_item_java.fish b/functions/_tide_item_java.fish index 2bd577f..902723f 100644 --- a/functions/_tide_item_java.fish +++ b/functions/_tide_item_java.fish @@ -1,3 +1,3 @@ function _tide_item_java - test -e pom.xml && _tide_print_item java $tide_java_icon' ' (set jv (java -version 2>&1 | head -1 | string split ' ')[3]; echo $jv | string trim -c '"') + test -e pom.xml && _tide_print_item java $tide_java_icon' ' (java --version | string split ' ')[2] end diff --git a/functions/tide/configure/configs/classic.fish b/functions/tide/configure/configs/classic.fish index dd547d8..af4fa27 100644 --- a/functions/tide/configure/configs/classic.fish +++ b/functions/tide/configure/configs/classic.fish @@ -32,6 +32,9 @@ tide_git_icon tide_go_bg_color 444444 tide_go_color 00ACD7 tide_go_icon  +tide_java_bg_color 444444 +tide_java_color ED8B00 +tide_java_icon '' tide_jobs_bg_color 444444 tide_jobs_color $_tide_color_dark_green tide_jobs_icon '' @@ -75,9 +78,6 @@ tide_right_prompt_suffix '' tide_rustc_bg_color 444444 tide_rustc_color F74C00 tide_rustc_icon '' -tide_java_bg_color 444444 -tide_java_color F74C00 -tide_java_icon '' tide_shlvl_bg_color 444444 tide_shlvl_color d78700 tide_shlvl_icon '' diff --git a/functions/tide/configure/configs/classic_16color.fish b/functions/tide/configure/configs/classic_16color.fish index 06f1b97..d57fabf 100644 --- a/functions/tide/configure/configs/classic_16color.fish +++ b/functions/tide/configure/configs/classic_16color.fish @@ -21,6 +21,8 @@ tide_git_color_untracked brblue tide_git_color_upstream brgreen tide_go_bg_color black tide_go_color brcyan +tide_java_bg_color black +tide_java_color yellow tide_jobs_bg_color black tide_jobs_color green tide_kubectl_bg_color black @@ -39,8 +41,6 @@ tide_pwd_color_dirs cyan tide_pwd_color_truncated_dirs magenta tide_rustc_bg_color black tide_rustc_color red -tide_java_bg_color black -tide_java_color red tide_shlvl_bg_color black tide_shlvl_color yellow tide_status_bg_color black diff --git a/functions/tide/configure/configs/lean.fish b/functions/tide/configure/configs/lean.fish index 88bcb2a..56440af 100644 --- a/functions/tide/configure/configs/lean.fish +++ b/functions/tide/configure/configs/lean.fish @@ -32,6 +32,9 @@ tide_git_icon tide_go_bg_color normal tide_go_color 00ACD7 tide_go_icon  +tide_java_bg_color normal +tide_java_color ED8B00 +tide_java_icon '' tide_jobs_bg_color normal tide_jobs_color $_tide_color_dark_green tide_jobs_icon '' @@ -75,9 +78,6 @@ tide_right_prompt_suffix '' tide_rustc_bg_color normal tide_rustc_color F74C00 tide_rustc_icon '' -tide_java_bg_color normal -tide_java_color F74C00 -tide_java_icon '' tide_shlvl_bg_color normal tide_shlvl_color d78700 tide_shlvl_icon '' diff --git a/functions/tide/configure/configs/lean_16color.fish b/functions/tide/configure/configs/lean_16color.fish index 5209e1e..fed97b5 100644 --- a/functions/tide/configure/configs/lean_16color.fish +++ b/functions/tide/configure/configs/lean_16color.fish @@ -21,6 +21,8 @@ tide_git_color_untracked brblue tide_git_color_upstream brgreen tide_go_bg_color normal tide_go_color brcyan +tide_java_bg_color normal +tide_java_color yellow tide_jobs_bg_color normal tide_jobs_color green tide_kubectl_bg_color normal @@ -39,8 +41,6 @@ tide_pwd_color_dirs cyan tide_pwd_color_truncated_dirs magenta tide_rustc_bg_color normal tide_rustc_color red -tide_java_bg_color normal -tide_java_color red tide_shlvl_bg_color normal tide_shlvl_color yellow tide_status_bg_color normal diff --git a/functions/tide/configure/configs/rainbow.fish b/functions/tide/configure/configs/rainbow.fish index 1654d97..d98dfb5 100644 --- a/functions/tide/configure/configs/rainbow.fish +++ b/functions/tide/configure/configs/rainbow.fish @@ -32,6 +32,9 @@ tide_git_icon tide_go_bg_color 00ACD7 tide_go_color 000000 tide_go_icon  +tide_java_bg_color ED8B00 +tide_java_color 000000 +tide_java_icon '' tide_jobs_bg_color 444444 tide_jobs_color 4E9A06 tide_jobs_icon '' @@ -75,9 +78,6 @@ tide_right_prompt_suffix '' tide_rustc_bg_color F74C00 tide_rustc_color 000000 tide_rustc_icon '' -tide_java_bg_color F74C00 -tide_java_color 000000 -tide_java_icon '' tide_shlvl_bg_color 808000 tide_shlvl_color 000000 tide_shlvl_icon '' diff --git a/functions/tide/configure/configs/rainbow_16color.fish b/functions/tide/configure/configs/rainbow_16color.fish index 7b338e5..2614204 100644 --- a/functions/tide/configure/configs/rainbow_16color.fish +++ b/functions/tide/configure/configs/rainbow_16color.fish @@ -21,6 +21,8 @@ tide_git_color_untracked black tide_git_color_upstream black tide_go_bg_color brcyan tide_go_color black +tide_java_bg_color yellow +tide_java_color black tide_jobs_bg_color brblack tide_jobs_color green tide_kubectl_bg_color blue @@ -39,8 +41,6 @@ tide_pwd_color_dirs brwhite tide_pwd_color_truncated_dirs white tide_rustc_bg_color red tide_rustc_color black -tide_java_bg_color red -tide_java_color black tide_shlvl_bg_color yellow tide_shlvl_color black tide_status_bg_color black From 63c83bd5aa15de5da2f991e96f90c816424544ee Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Thu, 6 Jan 2022 09:14:36 -0800 Subject: [PATCH 3/3] Add java item test --- tests/_tide_item_java.test.fish | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/_tide_item_java.test.fish diff --git a/tests/_tide_item_java.test.fish b/tests/_tide_item_java.test.fish new file mode 100644 index 0000000..0b62fa8 --- /dev/null +++ b/tests/_tide_item_java.test.fish @@ -0,0 +1,21 @@ +# RUN: %fish %s + +function _java + _tide_decolor (_tide_item_java) +end + +set -l javaDir (mktemp -d) +cd $javaDir + +mock java --version "echo 'openjdk 17.0.1 2021-10-19 +OpenJDK Runtime Environment (build 17.0.1+12) +OpenJDK 64-Bit Server VM (build 17.0.1+12, mixed mode)'" + +set -lx tide_java_icon  + +_java # CHECK: + +touch pom.xml +_java # CHECK:  17.0.1 + +rm -r $javaDir