From 091b183b836a332b4b9efc6ecb8939d6a4455dca Mon Sep 17 00:00:00 2001 From: tslil Date: Sun, 27 Jul 2025 19:48:46 +0100 Subject: [fish] improve jj prompt --- .gitignore | 1 + fish/functions/fish_jj_prompt.fish | 43 +++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..55fa165 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +emacs/inits/*.el diff --git a/fish/functions/fish_jj_prompt.fish b/fish/functions/fish_jj_prompt.fish index 7ab024e..b2fb5ba 100644 --- a/fish/functions/fish_jj_prompt.fish +++ b/fish/functions/fish_jj_prompt.fish @@ -7,33 +7,32 @@ function fish_jj_prompt --description 'Write out the jj prompt' return 1 end - jj log --ignore-working-copy --no-graph --color always -r @ -T ' + set parent_bmarks (jj log --no-graph -r 'bookmarks() & parents(@)' -T 'bookmarks.join(", ")') + + set template " surround( - " (", - ")", + ' (', + ')', separate( - " ", - bookmarks.join(", "), - if(empty, "∅"), + ' ', + if(empty, '∅', '● ' ++ self.diff().files().len()), coalesce( surround( - "\"", - "\"", - if( - description.first_line().substr(0, 12).starts_with(description.first_line()), - description.first_line().substr(0, 12), - description.first_line().substr(0, 11) ++ "…" - ) + '\"', + '\"', + truncate_end(12, description.first_line(), '…') ), - label("description placeholder", "?") + label('description placeholder', '?') + ), + change_id.shortest() ++ surround( + '<', '>', + bookmarks.join(', ') ), - "|", - change_id.shortest(), - commit_id.shortest(), - if(conflict, "X"), - if(divergent, "☇"), - if(hidden, "⬚"), + surround('~<', '>', \"$parent_bmarks\"), + if(conflict, 'X'), + if(divergent, '☇'), + if(hidden, '⬚'), ) - ) - ' 2>/dev/null + )" + jj log --no-graph --color always -r @ -T $template end -- cgit v1.2.3