Skip to content

Commit 11136f5

Browse files
committed
Add jj item
1 parent 44c521a commit 11136f5

File tree

4 files changed

+87
-3
lines changed

4 files changed

+87
-3
lines changed

functions/_tide_item_jj.fish

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
function _tide_item_jj
2+
if not command -sq jj; or not jj root --quiet &>/dev/null
3+
return 1
4+
end
5+
6+
set jj_status (jj log -r@ -n1 --no-graph --color always -T '
7+
separate(" ",
8+
bookmarks.map(|x| if(
9+
x.name().substr(0, 10).starts_with(x.name()),
10+
x.name().substr(0, 10),
11+
x.name().substr(0, 9) ++ "…")
12+
).join(" "),
13+
tags.map(|x| if(
14+
x.name().substr(0, 10).starts_with(x.name()),
15+
x.name().substr(0, 10),
16+
x.name().substr(0, 9) ++ "…")
17+
).join(" "),
18+
surround("\"","\"",
19+
if(
20+
description.first_line().substr(0, 24).starts_with(description.first_line()),
21+
description.first_line().substr(0, 24),
22+
description.first_line().substr(0, 23) ++ "…"
23+
)
24+
),
25+
change_id.shortest(),
26+
commit_id.shortest(),
27+
diff.files().len() ++ "m",
28+
diff.stat().total_added() ++ "+",
29+
diff.stat().total_removed() ++ "-",
30+
if(conflict, "conflict"),
31+
if(divergent, "divergent"),
32+
if(hidden, "hidden"),
33+
)' | string trim)
34+
_tide_print_item jj $tide_jj_icon' ' "($jj_status)"
35+
end

functions/_tide_remove_unusable_items.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function _tide_remove_unusable_items
22
# Remove tool-specific items for tools the machine doesn't have installed
33
set -l removed_items
4-
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
4+
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
55
contains $item $tide_left_prompt_items $tide_right_prompt_items || continue
66

77
set -l cli_names $item

functions/tide/configure/configs/classic.fish

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ tide_jobs_number_threshold 1000
5252
tide_kubectl_bg_color 444444
5353
tide_kubectl_color 326CE5
5454
tide_left_prompt_frame_enabled true
55-
tide_left_prompt_items pwd git newline
55+
tide_left_prompt_items pwd git jj newline
5656
tide_left_prompt_prefix ''
5757
tide_left_prompt_separator_diff_color 
5858
tide_left_prompt_separator_same_color 
@@ -79,7 +79,7 @@ tide_pwd_bg_color 444444
7979
tide_pwd_color_anchors $_tide_color_light_blue
8080
tide_pwd_color_dirs $_tide_color_dark_blue
8181
tide_pwd_color_truncated_dirs 8787AF
82-
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
82+
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
8383
tide_python_bg_color 444444
8484
tide_python_color 00AFAF
8585
tide_right_prompt_frame_enabled true

tests/_tide_item_jj.test.fish

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# RUN: %fish %s
2+
_tide_parent_dirs
3+
4+
function _jj
5+
_tide_decolor (_tide_item_jj)
6+
end
7+
8+
set -l tmpdir (mktemp -d)
9+
cd $tmpdir
10+
11+
mock command -sq jj "echo '/tmp/usr/bin/jj'"
12+
mock jj root --quiet "echo '/tmp/usr/repo'"
13+
mock jj log -r@ -n1 --no-graph --color always -T '
14+
separate(" ",
15+
bookmarks.map(|x| if(
16+
x.name().substr(0, 10).starts_with(x.name()),
17+
x.name().substr(0, 10),
18+
x.name().substr(0, 9) ++ "…")
19+
).join(" "),
20+
tags.map(|x| if(
21+
x.name().substr(0, 10).starts_with(x.name()),
22+
x.name().substr(0, 10),
23+
x.name().substr(0, 9) ++ "…")
24+
).join(" "),
25+
surround("\"","\"",
26+
if(
27+
description.first_line().substr(0, 24).starts_with(description.first_line()),
28+
description.first_line().substr(0, 24),
29+
description.first_line().substr(0, 23) ++ "…"
30+
)
31+
),
32+
change_id.shortest(),
33+
commit_id.shortest(),
34+
diff.files().len() ++ "m",
35+
diff.stat().total_added() ++ "+",
36+
diff.stat().total_removed() ++ "-",
37+
if(conflict, "conflict"),
38+
if(divergent, "divergent"),
39+
if(hidden, "hidden"),
40+
)' "echo 'my-bookmark \"bugfixes\" p a 1m 39+ 5-'"
41+
42+
set -lx tide_deno_icon 󱗆
43+
44+
_jj # CHECK:
45+
46+
touch .jj
47+
_jj # CHECK: 󱗆 (my-bookmark "bugfixes" p a 1m 39+ 5-)
48+
49+
command rm -r $tmpdir

0 commit comments

Comments
 (0)