Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions functions/_tide_item_jj.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
function _tide_item_jj
jj root --quiet &>/dev/null || return

# We want tide to define the colors so disable them
set -l f
jj log --ignore-working-copy --no-graph --color never -r @ -T '
concat(
change_id.shortest().prefix(), "\0", change_id.shortest().rest(), "\0",
commit_id.shortest().prefix(), "\0", commit_id.shortest().rest(), "\0",
bookmarks.map(|b| b.name()).join(" "), "\0",
if(
description.first_line().substr(0, 24).starts_with(description.first_line()),
description.first_line().substr(0, 24),
description.first_line().substr(0, 23) ++ "…"
), "\0",
if(empty, "1", ""), "\0", if(conflict, "1", ""), "\0",
if(divergent, "1", ""), "\0", if(hidden, "1", ""), "\0",
diff.files().len(), "\0", diff.stat().total_added(), "\0", diff.stat().total_removed(), "\0",
)' 2>/dev/null | while read -lz field
set -a f $field
end

set -l change_prefix $f[1]
set -l change_rest $f[2]
set -l commit_prefix $f[3]
set -l commit_rest $f[4]
set -l bookmarks $f[5]
set -l description $f[6]
set -l empty $f[7]
set -l conflict $f[8]
set -l divergent $f[9]
set -l hidden $f[10]
set -l files $f[11]
set -l added $f[12]
set -l removed $f[13]

if test -n "$conflict$divergent"
set -g tide_jj_bg_color $tide_jj_bg_color_urgent
else if test -z "$empty"
set -g tide_jj_bg_color $tide_jj_bg_color_unstable
end

_tide_print_item jj (set_color $tide_jj_color_change_id)' ' (
set_color $tide_jj_color_change_id
echo -ns $change_prefix
set_color $tide_jj_color_id_shadow
echo -ns $change_rest

set_color $tide_jj_color_commit_id
echo -ns ' '$commit_prefix
set_color $tide_jj_color_id_shadow
echo -ns $commit_rest

test -n "$bookmarks" && begin
set_color $tide_jj_color_bookmarks
echo -ns ' '$bookmarks
end

test -n "$description" && begin
set_color $tide_jj_color_description
echo -ns ' "'$description'"'
end

test -n "$conflict" && begin
set_color $tide_jj_color_conflict
echo -ns ' conflict'
end

test -n "$divergent" && begin
set_color $tide_jj_color_divergent
echo -ns ' divergent'
end

test -n "$hidden" && begin
set_color $tide_jj_color_divergent
echo -ns ' hidden'
end

test "$files" != 0 && begin
set_color $tide_jj_color_diff_added
echo -ns ' +'$added
set_color $tide_jj_color_diff_removed
echo -ns ' -'$removed
end
)
end
2 changes: 1 addition & 1 deletion functions/_tide_remove_unusable_items.fish
Original file line number Diff line number Diff line change
@@ -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 gcloud git go java jj 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
Expand Down
14 changes: 13 additions & 1 deletion functions/tide/configure/configs/classic.fish
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,25 @@ tide_go_bg_color 444444
tide_go_color 00ACD7
tide_java_bg_color 444444
tide_java_color ED8B00
tide_jj_bg_color 444444
tide_jj_bg_color_unstable 444444
tide_jj_bg_color_urgent 444444
tide_jj_color_bookmarks $_tide_color_light_blue
tide_jj_color_change_id $_tide_color_green
tide_jj_color_commit_id $_tide_color_dark_blue
tide_jj_color_conflict FF0000
tide_jj_color_description 87875F
tide_jj_color_diff_added $_tide_color_dark_green
tide_jj_color_diff_removed CC0000
tide_jj_color_divergent $_tide_color_gold
tide_jj_color_id_shadow 808080
tide_jobs_bg_color 444444
tide_jobs_color $_tide_color_dark_green
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 
Expand Down
12 changes: 12 additions & 0 deletions functions/tide/configure/configs/classic_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ tide_go_bg_color black
tide_go_color brcyan
tide_java_bg_color black
tide_java_color yellow
tide_jj_bg_color black
tide_jj_bg_color_unstable black
tide_jj_bg_color_urgent black
tide_jj_color_bookmarks brblue
tide_jj_color_change_id brgreen
tide_jj_color_commit_id blue
tide_jj_color_conflict brred
tide_jj_color_description brblack
tide_jj_color_diff_added green
tide_jj_color_diff_removed red
tide_jj_color_divergent bryellow
tide_jj_color_id_shadow brblack
tide_jobs_bg_color black
tide_jobs_color green
tide_kubectl_bg_color black
Expand Down
14 changes: 13 additions & 1 deletion functions/tide/configure/configs/lean.fish
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,25 @@ tide_go_bg_color normal
tide_go_color 00ACD7
tide_java_bg_color normal
tide_java_color ED8B00
tide_jj_bg_color 444444
tide_jj_bg_color_unstable 444444
tide_jj_bg_color_urgent 444444
tide_jj_color_bookmarks $_tide_color_light_blue
tide_jj_color_change_id $_tide_color_green
tide_jj_color_commit_id $_tide_color_dark_blue
tide_jj_color_conflict FF0000
tide_jj_color_description 87875F
tide_jj_color_diff_added $_tide_color_dark_green
tide_jj_color_diff_removed CC0000
tide_jj_color_divergent $_tide_color_gold
tide_jj_color_id_shadow 808080
tide_jobs_bg_color normal
tide_jobs_color $_tide_color_dark_green
tide_jobs_number_threshold 1000
tide_kubectl_bg_color normal
tide_kubectl_color 326CE5
tide_left_prompt_frame_enabled false
tide_left_prompt_items pwd git newline character
tide_left_prompt_items pwd git jj newline character
tide_left_prompt_prefix ''
tide_left_prompt_separator_diff_color ' '
tide_left_prompt_separator_same_color ' '
Expand Down
12 changes: 12 additions & 0 deletions functions/tide/configure/configs/lean_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ tide_go_bg_color normal
tide_go_color brcyan
tide_java_bg_color normal
tide_java_color yellow
tide_jj_bg_color black
tide_jj_bg_color_unstable black
tide_jj_bg_color_urgent black
tide_jj_color_bookmarks brblue
tide_jj_color_change_id brgreen
tide_jj_color_commit_id blue
tide_jj_color_conflict brred
tide_jj_color_description brblack
tide_jj_color_diff_added green
tide_jj_color_diff_removed red
tide_jj_color_divergent bryellow
tide_jj_color_id_shadow brblack
tide_jobs_bg_color normal
tide_jobs_color green
tide_kubectl_bg_color normal
Expand Down
14 changes: 13 additions & 1 deletion functions/tide/configure/configs/rainbow.fish
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,25 @@ tide_go_bg_color 00ACD7
tide_go_color 000000
tide_java_bg_color ED8B00
tide_java_color 000000
tide_jj_bg_color 4E9A06
tide_jj_bg_color_unstable C4A000
tide_jj_bg_color_urgent CC0000
tide_jj_color_bookmarks 000000
tide_jj_color_change_id 000000
tide_jj_color_commit_id 000000
tide_jj_color_conflict 000000
tide_jj_color_description 000000
tide_jj_color_diff_added 000000
tide_jj_color_diff_removed 000000
tide_jj_color_divergent 000000
tide_jj_color_id_shadow 000000
tide_jobs_bg_color 444444
tide_jobs_color 4E9A06
tide_jobs_number_threshold 1000
tide_kubectl_bg_color 326CE5
tide_kubectl_color 000000
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 
Expand Down
12 changes: 12 additions & 0 deletions functions/tide/configure/configs/rainbow_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ tide_go_bg_color brcyan
tide_go_color black
tide_java_bg_color yellow
tide_java_color black
tide_jj_bg_color green
tide_jj_bg_color_unstable yellow
tide_jj_bg_color_urgent red
tide_jj_color_bookmarks black
tide_jj_color_change_id black
tide_jj_color_commit_id black
tide_jj_color_conflict black
tide_jj_color_description black
tide_jj_color_diff_added black
tide_jj_color_diff_removed black
tide_jj_color_divergent black
tide_jj_color_id_shadow black
tide_jobs_bg_color brblack
tide_jobs_color green
tide_kubectl_bg_color blue
Expand Down
3 changes: 3 additions & 0 deletions functions/tide/configure/functions/_fake_tide_item_jj.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function _fake_tide_item_jj
_fake_tide_print_item jj (set_color $fake_tide_jj_color_change_id)' ' xqz desc
end
35 changes: 35 additions & 0 deletions tests/_tide_item_jj.test.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# RUN: %fish %s
_tide_parent_dirs

function _jj
_tide_decolor (_tide_item_jj)
end

function _mock_jj
set -g _jjfields $argv
function jj --inherit-variable _jjfields
test "$argv[1]" = root && return 0
printf '%s\0' $_jjfields
end
end

function jj
return 1
end
_jj # CHECK:

# Clean, empty working copy (change + commit ids only)
_mock_jj q '' z '' '' '' 1 '' '' '' 0 0 0
_jj # CHECK: jj q z

# Bookmark, description and diff stats
_mock_jj ab c de f main 'fix parser' '' '' '' '' 2 40 3
_jj # CHECK: jj abc def main "fix parser" +40 -3

# Conflict
_mock_jj xy '' zz '' '' '' '' 1 '' '' 1 5 0
_jj # CHECK: jj xy zz conflict +5 -0

# Divergent, no diff
_mock_jj mm '' nn '' '' '' '' '' 1 '' 0 0 0
_jj # CHECK: jj mm nn divergent
Loading