From 7dad183fbfeef8ab4f5f4ae02e8d804e19dc2484 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 8 Aug 2025 13:09:49 +0200 Subject: [PATCH] Upgrade Tide --- functions/_tide_detect_os.fish | 3 +- functions/_tide_item_bun.fish | 6 ++++ functions/_tide_item_git.fish | 2 +- functions/_tide_parent_dirs.fish | 13 ++++---- functions/_tide_remove_unusable_items.fish | 2 +- functions/_tide_sub_bug-report.fish | 30 +++++++++---------- functions/fish_prompt.fish | 23 +++++++------- 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 + 15 files changed, 63 insertions(+), 43 deletions(-) create mode 100644 functions/_tide_item_bun.fish diff --git a/functions/_tide_detect_os.fish b/functions/_tide_detect_os.fish index cf38388..bb58d07 100644 --- a/functions/_tide_detect_os.fish +++ b/functions/_tide_detect_os.fish @@ -10,9 +10,8 @@ function _tide_detect_os printf %s\n  FFFFFF 00CCFF # https://answers.microsoft.com/en-us/windows/forum/all/what-is-the-official-windows-8-blue-rgb-or-hex/fd57144b-f69b-42d8-8c21-6ca911646e44 case linux if test (uname -o) = Android - echo ﲎ # This character is evil and messes up code display, so it's put on its own line # https://developer.android.com/distribute/marketing-tools/brand-guidelines - printf %s\n 3DDC84 3C3F41 # fg is from above link, bg is from Android Studio default dark theme + printf %s\n  3DDC84 3C3F41 # fg is from above link, bg is from Android Studio default dark theme else _tide_detect_os_linux_cases /etc/os-release ID || _tide_detect_os_linux_cases /etc/os-release ID_LIKE || diff --git a/functions/_tide_item_bun.fish b/functions/_tide_item_bun.fish new file mode 100644 index 0000000..b39fd72 --- /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_git.fish b/functions/_tide_item_git.fish index 3154acc..56e1e31 100644 --- a/functions/_tide_item_git.fish +++ b/functions/_tide_item_git.fish @@ -50,7 +50,7 @@ function _tide_item_git (0|(?.*))\n(0|(?.*))(\n(0|(?.*))\t(0|(?.*)))?' \ "$(git $_set_dir_opt stash list 2>/dev/null | count string match -r ^UU $stat | count - string match -r ^[ADMR]. $stat | count + string match -r ^[ADMR] $stat | count string match -r ^.[ADMR] $stat | count string match -r '^\?\?' $stat | count git rev-list --count --left-right @{upstream}...HEAD 2>/dev/null)" diff --git a/functions/_tide_parent_dirs.fish b/functions/_tide_parent_dirs.fish index 9f31b04..00d8a14 100644 --- a/functions/_tide_parent_dirs.fish +++ b/functions/_tide_parent_dirs.fish @@ -1,7 +1,10 @@ function _tide_parent_dirs --on-variable PWD - set -g _tide_parent_dirs (string escape ( - for dir in (string split / -- $PWD) - set -la parts $dir - string join / -- $parts - end)) + set -g _tide_parent_dirs ( + string escape ( + for dir in (string split / -- $PWD) + set -fa parts $dir + string join / -- $parts + end + ) + ) end diff --git a/functions/_tide_remove_unusable_items.fish b/functions/_tide_remove_unusable_items.fish index deb4c10..b1d9b28 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_sub_bug-report.fish b/functions/_tide_sub_bug-report.fish index a8065c8..82f08c0 100644 --- a/functions/_tide_sub_bug-report.fish +++ b/functions/_tide_sub_bug-report.fish @@ -11,14 +11,14 @@ function _tide_sub_bug-report set --long | string match -r "^_?tide.*" | # Get only tide variables string match -r --invert "^_tide_prompt_var.*" # Remove _tide_prompt_var else - set -l fish_version ($fish_path --version | string match -r "fish, version (\d\.\d\.\d)")[2] - _tide_check_version Fish fish-shell/fish-shell "(\d\.\d\.\d)" $fish_version || return + $fish_path --version | string match -qr "fish, version (?.*)" + _tide_check_version Fish fish-shell/fish-shell "(?[\d.]+)" $fish_version || return - set -l tide_version (tide --version | string match -r "tide, version (\d\.\d\.\d)")[2] - _tide_check_version Tide IlanCosman/tide "v(\d\.\d\.\d)" $tide_version || return + tide --version | string match -qr "tide, version (?.*)" + _tide_check_version Tide IlanCosman/tide "v(?[\d.]+)" $tide_version || return if command --query git - test (git --version | string match -r "git version ([\d\.]*)" | string replace --all . '')[2] -gt 2220 + test (path sort (git --version) "git version 2.22.0")[1] = "git version 2.22.0" _tide_check_condition \ "Your git version is too old." \ "Tide requires at least version 2.22." \ @@ -32,11 +32,12 @@ function _tide_sub_bug-report "Please uninstall it before submitting a bug report." || return if not set -q _flag_check - set -l fish_startup_time ($fish_path -ic "time $fish_path -c exit" 2>| - string match -r "Executed in(.*)fish" | string trim)[2] + $fish_path -ic "time $fish_path -c exit" 2>| + string match -rg "Executed in(.*)fish" | + string trim | read -l fish_startup_time - read --local --prompt-str "What operating system are you using? (e.g Ubuntu 20.04): " os - read --local --prompt-str "What terminal emulator are you using? (e.g Kitty): " terminal_emulator + read -l --prompt-str "What operating system are you using? (e.g Ubuntu 20.04): " os + read -l --prompt-str "What terminal emulator are you using? (e.g Kitty): " terminal_emulator printf '%b\n' "\nPlease copy the following information into the issue:\n" \ "fish version: $fish_version" \ @@ -50,15 +51,14 @@ function _tide_sub_bug-report end end -function _tide_check_version -a program_name repo_name regex_to_get_version current_version - curl --silent https://github.com/$repo_name/releases/latest | - string match -r ".*$repo_name/releases/tag/$regex_to_get_version.*" | - read --local --line __ latestVersion +function _tide_check_version -a program_name repo_name regex_to_get_v installed_version + curl -sL https://github.com/$repo_name/releases/latest | + string match -qr "https://github.com/$repo_name/releases/tag/$regex_to_get_v" - string match --quiet -r "^$latestVersion" "$current_version" + string match -qr "^$v" "$installed_version" # Allow git versions, e.g 3.3.1-701-gceade1629 _tide_check_condition \ "Your $program_name version is out of date." \ - "The latest is $latestVersion. You have $current_version." \ + "The latest is $v. You have $installed_version." \ "Please update before submitting a bug report." end diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 3b58b7b..994513d 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -28,7 +28,7 @@ if contains newline $_tide_left_items # two line prompt initialization test "$tide_left_prompt_frame_enabled" = true && set -l top_left_frame "$prompt_and_frame_color╭─" && set -l bot_left_frame "$prompt_and_frame_color╰─" && - set column_offset (math $column_offset-2) + set column_offset 3 test "$tide_right_prompt_frame_enabled" = true && set -l top_right_frame "$prompt_and_frame_color─╮" && set -l bot_right_frame "$prompt_and_frame_color─╯" && @@ -145,21 +145,20 @@ end" end end -eval "function _tide_on_fish_exit --on-event fish_exit +# Inheriting instead of evaling because here load time is more important than runtime +function _tide_on_fish_exit --on-event fish_exit --inherit-variable prompt_var set -e $prompt_var -end" +end if test "$tide_prompt_transient_enabled" = true function _tide_enter_transient - # If the commandline will be executed, or is empty - if commandline --is-valid || test -z "$(commandline)" - # Pager open usually means selecting, not running - # Can be untrue, but it's better than the alternative - if not commandline --paging-mode - set -g _tide_transient - set -g _tide_repaint - commandline -f repaint - end + # If the commandline will be executed or is empty, and the pager is not open + # Pager open usually means selecting, not running + # Can be untrue, but it's better than the alternative + if commandline --is-valid || test -z "$(commandline)" && not commandline --paging-mode + set -g _tide_transient + set -g _tide_repaint + commandline -f repaint end commandline -f execute end diff --git a/functions/tide.fish b/functions/tide.fish index 092a722..4b115a1 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 8973cbc..6f09bba 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 670170f..fe730c5 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 a958a17..db3f1d2 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 16c2511..699ce45 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 60c1592..79e9cb4 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 a040f58..5d20611 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 70611cd..a687bed 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 ▶