dotfiles/dot-config/fish/functions/fish_jj_prompt.fish

46 lines
1.4 KiB
Fish
Raw Normal View History

2024-07-18 12:23:05 -04:00
# https://gist.github.com/hroi/d0dc0e95221af858ee129fd66251897e/
# Place me in ~/.config/fish/functions
# Then add me to `fish_vcs_prompt`: `funced fish_vcs_prompt`
function fish_jj_prompt --description 'Write out the jj prompt'
# Is jj installed?
if not command -sq jj
return 1
end
# Are we in a jj repo?
if not jj root --quiet &>/dev/null
return 1
end
# Generate prompt
2024-07-18 13:26:43 -04:00
jj log --ignore-working-copy --no-graph --color always -r @ -T '
2024-07-18 12:23:05 -04:00
surround(
" (",
")",
separate(
" ",
2024-11-01 09:13:53 -04:00
bookmarks.join(", "),
2024-07-18 12:23:05 -04:00
coalesce(
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) ++ "…"
)
),
"(no description set)"
),
change_id.shortest(),
commit_id.shortest(),
if(conflict, "(conflict)"),
if(empty, "(empty)"),
if(divergent, "(divergent)"),
if(hidden, "(hidden)"),
)
)
'
end