From 6bfc972c49052456533fb05e9aedecbe572302eb Mon Sep 17 00:00:00 2001 From: Eamon Caton Date: Sat, 14 Sep 2024 00:17:43 -0700 Subject: [PATCH] Add jj item --- functions/_tide_item_jj.fish | 35 +++++++++++++++++++ functions/_tide_remove_unusable_items.fish | 2 +- functions/tide/configure/configs/classic.fish | 4 +-- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 functions/_tide_item_jj.fish diff --git a/functions/_tide_item_jj.fish b/functions/_tide_item_jj.fish new file mode 100644 index 00000000..51b6a178 --- /dev/null +++ b/functions/_tide_item_jj.fish @@ -0,0 +1,35 @@ +function _tide_item_jj + if not command -sq jj; or not jj root --quiet &>/dev/null + return 1 + end + + set jj_status (jj log -r@ -n1 --no-graph --color always -T ' + separate(" ", + bookmarks.map(|x| if( + x.name().substr(0, 10).starts_with(x.name()), + x.name().substr(0, 10), + x.name().substr(0, 9) ++ "…") + ).join(" "), + tags.map(|x| if( + x.name().substr(0, 10).starts_with(x.name()), + x.name().substr(0, 10), + x.name().substr(0, 9) ++ "…") + ).join(" "), + surround("\"","\"", + if( + description.first_line().substr(0, 24).starts_with(description.first_line()), + description.first_line().substr(0, 24), + description.first_line().substr(0, 23) ++ "…" + ) + ), + change_id.shortest(), + commit_id.shortest(), + diff.files().len() ++ "m", + diff.stat().total_added() ++ "+", + diff.stat().total_removed() ++ "-", + if(conflict, "conflict"), + if(divergent, "divergent"), + if(hidden, "hidden"), + )' | string trim) + _tide_print_item jj $tide_jj_icon' ' "($jj_status)" +end diff --git a/functions/_tide_remove_unusable_items.fish b/functions/_tide_remove_unusable_items.fish index b1d9b283..50023a27 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 bun 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 jj 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/configure/configs/classic.fish b/functions/tide/configure/configs/classic.fish index 6f09bbaf..0f5f2f3e 100644 --- a/functions/tide/configure/configs/classic.fish +++ b/functions/tide/configure/configs/classic.fish @@ -52,7 +52,7 @@ tide_jobs_number_threshold 1000 tide_kubectl_bg_color 444444 tide_kubectl_color 326CE5 tide_left_prompt_frame_enabled true -tide_left_prompt_items pwd git newline +tide_left_prompt_items pwd git jj newline tide_left_prompt_prefix '' tide_left_prompt_separator_diff_color  tide_left_prompt_separator_same_color  @@ -79,7 +79,7 @@ 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 bun.lockb Cargo.toml composer.json CVS go.mod package.json build.zig +tide_pwd_markers .bzr .citc .git .hg .jj .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