From d220b9d93b4a94c2d3d5a5f33966006dc38dc1f6 Mon Sep 17 00:00:00 2001 From: Will Stone <654103+will-stone@users.noreply.github.com> Date: Tue, 23 Jan 2024 12:32:03 +0000 Subject: [PATCH 1/2] Add support for Bun --- CHANGELOG.md | 6 ++++++ functions/_tide_item_bun.fish | 6 ++++++ functions/_tide_item_node.fish | 4 +++- functions/_tide_remove_unusable_items.fish | 2 +- functions/tide.fish | 2 +- functions/tide/configure/configs/classic.fish | 6 ++++-- .../configure/configs/classic_16color.fish | 2 ++ functions/tide/configure/configs/lean.fish | 6 ++++-- .../tide/configure/configs/lean_16color.fish | 2 ++ functions/tide/configure/configs/rainbow.fish | 6 ++++-- .../configure/configs/rainbow_16color.fish | 2 ++ functions/tide/configure/icons.fish | 1 + tests/_tide_item_bun.test.fish | 19 +++++++++++++++++++ 13 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 functions/_tide_item_bun.fish create mode 100644 tests/_tide_item_bun.test.fish diff --git a/CHANGELOG.md b/CHANGELOG.md index 449de39a..9d3b3ce6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [v6.2.0][] (Jan 23 2024) + +### Features + +- Add a new `bun` item. + ## [v6.1.1][] (Dec 27 2023) ### Bug fixes diff --git a/functions/_tide_item_bun.fish b/functions/_tide_item_bun.fish new file mode 100644 index 00000000..b39fd72d --- /dev/null +++ b/functions/_tide_item_bun.fish @@ -0,0 +1,6 @@ +function _tide_item_bun + if path is $_tide_parent_dirs/bun.lockb + bun --version | string match -qr "(?.*)" + _tide_print_item bun $tide_bun_icon' ' $v + end +end diff --git a/functions/_tide_item_node.fish b/functions/_tide_item_node.fish index fc57832b..07777ff1 100644 --- a/functions/_tide_item_node.fish +++ b/functions/_tide_item_node.fish @@ -1,5 +1,7 @@ function _tide_item_node - if path is $_tide_parent_dirs/package.json + if path is $_tide_parent_dirs/package.json and + # If Bun is detected assume that is being used over node + not path is $_tide_parent_dirs/bun.lockb node --version | string match -qr "v(?.*)" _tide_print_item node $tide_node_icon' ' $v end diff --git a/functions/_tide_remove_unusable_items.fish b/functions/_tide_remove_unusable_items.fish index deb4c104..b1d9b283 100644 --- a/functions/_tide_remove_unusable_items.fish +++ b/functions/_tide_remove_unusable_items.fish @@ -1,7 +1,7 @@ function _tide_remove_unusable_items # Remove tool-specific items for tools the machine doesn't have installed set -l removed_items - for item in aws crystal direnv distrobox docker elixir gcloud git go java kubectl nix_shell node php pulumi python ruby rustc terraform toolbox zig + for item in aws bun crystal direnv distrobox docker elixir gcloud git go java kubectl nix_shell node php pulumi python ruby rustc terraform toolbox zig contains $item $tide_left_prompt_items $tide_right_prompt_items || continue set -l cli_names $item diff --git a/functions/tide.fish b/functions/tide.fish index 092a7224..4b115a1f 100644 --- a/functions/tide.fish +++ b/functions/tide.fish @@ -2,7 +2,7 @@ function tide --description 'Manage your Tide prompt' argparse --stop-nonopt v/version h/help -- $argv if set -q _flag_version - echo 'tide, version 6.1.1' + echo 'tide, version 6.2.0' else if set -q _flag_help _tide_help else if functions --query _tide_sub_$argv[1] diff --git a/functions/tide/configure/configs/classic.fish b/functions/tide/configure/configs/classic.fish index 8973cbc2..6f09bbaf 100644 --- a/functions/tide/configure/configs/classic.fish +++ b/functions/tide/configure/configs/classic.fish @@ -1,5 +1,7 @@ tide_aws_bg_color 444444 tide_aws_color FF9900 +tide_bun_bg_color 14151A +tide_bun_color FBF0DF tide_character_color $_tide_color_green tide_character_color_failure FF0000 tide_cmd_duration_bg_color 444444 @@ -77,11 +79,11 @@ tide_pwd_bg_color 444444 tide_pwd_color_anchors $_tide_color_light_blue tide_pwd_color_dirs $_tide_color_dark_blue tide_pwd_color_truncated_dirs 8787AF -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 build.zig +tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform bun.lockb Cargo.toml composer.json CVS go.mod package.json build.zig tide_python_bg_color 444444 tide_python_color 00AFAF tide_right_prompt_frame_enabled true -tide_right_prompt_items status cmd_duration context jobs direnv node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig +tide_right_prompt_items status cmd_duration context jobs direnv bun node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig tide_right_prompt_prefix  tide_right_prompt_separator_diff_color  tide_right_prompt_separator_same_color  diff --git a/functions/tide/configure/configs/classic_16color.fish b/functions/tide/configure/configs/classic_16color.fish index 670170f5..fe730c5f 100644 --- a/functions/tide/configure/configs/classic_16color.fish +++ b/functions/tide/configure/configs/classic_16color.fish @@ -1,5 +1,7 @@ tide_aws_bg_color black tide_aws_color yellow +tide_bun_bg_color black +tide_bun_color white tide_character_color brgreen tide_character_color_failure brred tide_cmd_duration_bg_color black diff --git a/functions/tide/configure/configs/lean.fish b/functions/tide/configure/configs/lean.fish index a958a175..db3f1d20 100644 --- a/functions/tide/configure/configs/lean.fish +++ b/functions/tide/configure/configs/lean.fish @@ -1,5 +1,7 @@ tide_aws_bg_color normal tide_aws_color FF9900 +tide_bun_bg_color normal +tide_bun_color FBF0DF tide_character_color $_tide_color_green tide_character_color_failure FF0000 tide_cmd_duration_bg_color normal @@ -77,11 +79,11 @@ tide_pwd_bg_color normal tide_pwd_color_anchors $_tide_color_light_blue tide_pwd_color_dirs $_tide_color_dark_blue tide_pwd_color_truncated_dirs 8787AF -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 build.zig +tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform bun.lockb Cargo.toml composer.json CVS go.mod package.json build.zig tide_python_bg_color normal tide_python_color 00AFAF tide_right_prompt_frame_enabled false -tide_right_prompt_items status cmd_duration context jobs direnv node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig +tide_right_prompt_items status cmd_duration context jobs direnv bun node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig tide_right_prompt_prefix ' ' tide_right_prompt_separator_diff_color ' ' tide_right_prompt_separator_same_color ' ' diff --git a/functions/tide/configure/configs/lean_16color.fish b/functions/tide/configure/configs/lean_16color.fish index 16c2511d..699ce45a 100644 --- a/functions/tide/configure/configs/lean_16color.fish +++ b/functions/tide/configure/configs/lean_16color.fish @@ -1,5 +1,7 @@ tide_aws_bg_color normal tide_aws_color yellow +tide_bun_bg_color normal +tide_bun_color white tide_character_color brgreen tide_character_color_failure brred tide_cmd_duration_bg_color normal diff --git a/functions/tide/configure/configs/rainbow.fish b/functions/tide/configure/configs/rainbow.fish index 60c15925..79e9cb4a 100644 --- a/functions/tide/configure/configs/rainbow.fish +++ b/functions/tide/configure/configs/rainbow.fish @@ -1,5 +1,7 @@ tide_aws_bg_color FF9900 tide_aws_color 232F3E +tide_bun_bg_color FBF0DF +tide_bun_color 14151A tide_character_color $_tide_color_green tide_character_color_failure FF0000 tide_cmd_duration_bg_color C4A000 @@ -77,11 +79,11 @@ tide_pwd_bg_color 3465A4 tide_pwd_color_anchors E4E4E4 tide_pwd_color_dirs E4E4E4 tide_pwd_color_truncated_dirs BCBCBC -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 build.zig +tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform bun.lockb Cargo.toml composer.json CVS go.mod package.json build.zig tide_python_bg_color 444444 tide_python_color 00AFAF tide_right_prompt_frame_enabled true -tide_right_prompt_items status cmd_duration context jobs direnv node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig +tide_right_prompt_items status cmd_duration context jobs direnv bun node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig tide_right_prompt_prefix  tide_right_prompt_separator_diff_color  tide_right_prompt_separator_same_color  diff --git a/functions/tide/configure/configs/rainbow_16color.fish b/functions/tide/configure/configs/rainbow_16color.fish index a040f584..5d206115 100644 --- a/functions/tide/configure/configs/rainbow_16color.fish +++ b/functions/tide/configure/configs/rainbow_16color.fish @@ -1,5 +1,7 @@ tide_aws_bg_color yellow tide_aws_color brblack +tide_bun_bg_color white +tide_bun_color black tide_character_color brgreen tide_character_color_failure brred tide_cmd_duration_bg_color yellow diff --git a/functions/tide/configure/icons.fish b/functions/tide/configure/icons.fish index 70611cdf..a687bed2 100644 --- a/functions/tide/configure/icons.fish +++ b/functions/tide/configure/icons.fish @@ -1,4 +1,5 @@ tide_aws_icon  # Actual aws glyph is harder to see +tide_bun_icon 󰳓 tide_character_icon ❯ tide_character_vi_icon_default ❮ tide_character_vi_icon_replace ▶ diff --git a/tests/_tide_item_bun.test.fish b/tests/_tide_item_bun.test.fish new file mode 100644 index 00000000..84c7bd5b --- /dev/null +++ b/tests/_tide_item_bun.test.fish @@ -0,0 +1,19 @@ +# RUN: %fish %s +_tide_parent_dirs + +function _bun + _tide_decolor (_tide_item_bun) +end + +set -l tmpdir (mktemp -d) +cd $tmpdir + +mock bun --version "echo 1.0.24" +set -lx tide_bun_icon 󰳓 + +_bun # CHECK: + +touch bun.lockb +_bun # CHECK: 󰳓 1.0.24 + +command rm -r $tmpdir From d8d07f8361e6406953319c82369786560bcb7808 Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Thu, 25 Jan 2024 12:10:41 -0800 Subject: [PATCH 2/2] Fixes --- CHANGELOG.md | 5 +++-- functions/_tide_item_node.fish | 4 +--- functions/tide.fish | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d3b3ce6..ce7bea66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ # Changelog -## [v6.2.0][] (Jan 23 2024) +## [v6.2.0][] (???) ### Features -- Add a new `bun` item. +- Add a new `bun` item ([#485][] - @will-stone) ## [v6.1.1][] (Dec 27 2023) @@ -585,6 +585,7 @@ [#470]: https://github.com/IlanCosman/tide/issues/470 [#472]: https://github.com/IlanCosman/tide/issues/472 [#474]: https://github.com/IlanCosman/tide/issues/474 +[#485]: https://github.com/IlanCosman/tide/issues/485 [prettier action]: https://github.com/actionsx/prettier [super-linter]: https://github.com/github/super-linter [v1.0.0]: https://github.com/IlanCosman/tide/tree/v1.0.0 diff --git a/functions/_tide_item_node.fish b/functions/_tide_item_node.fish index 07777ff1..fc57832b 100644 --- a/functions/_tide_item_node.fish +++ b/functions/_tide_item_node.fish @@ -1,7 +1,5 @@ function _tide_item_node - if path is $_tide_parent_dirs/package.json and - # If Bun is detected assume that is being used over node - not path is $_tide_parent_dirs/bun.lockb + if path is $_tide_parent_dirs/package.json node --version | string match -qr "v(?.*)" _tide_print_item node $tide_node_icon' ' $v end diff --git a/functions/tide.fish b/functions/tide.fish index 4b115a1f..092a7224 100644 --- a/functions/tide.fish +++ b/functions/tide.fish @@ -2,7 +2,7 @@ function tide --description 'Manage your Tide prompt' argparse --stop-nonopt v/version h/help -- $argv if set -q _flag_version - echo 'tide, version 6.2.0' + echo 'tide, version 6.1.1' else if set -q _flag_help _tide_help else if functions --query _tide_sub_$argv[1]