Skip to content

Instantly share code, notes, and snippets.

@camtheman256
Forked from hroi/fish_jj_prompt.fish
Last active May 29, 2025 15:56
Show Gist options
  • Save camtheman256/028aa2f1ced68cd435093a2d4680cf88 to your computer and use it in GitHub Desktop.
Save camtheman256/028aa2f1ced68cd435093a2d4680cf88 to your computer and use it in GitHub Desktop.
Jujutsu (jj) prompt for fish-shell with some modifications to use the label function to add colouring
# Place me in ~/.config/fish/functions
# Then add me to `fish_vcs_prompt`: `funced fish_vcs_prompt` and save it to
# your personal config: `funcsave 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
jj log --ignore-working-copy --no-graph --color always -r @ -T '
surround(
" (",
")",
separate(
" ",
bookmarks.join(", "),
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) ++ "…"
)
),
label(if(empty, "empty"), description_placeholder)
),
change_id.shortest(),
commit_id.shortest(),
if(conflict, label("conflict", "(conflict)")),
if(empty, label("empty", "(empty)")),
if(divergent, "(divergent)"),
if(hidden, "(hidden)"),
)
)
'
end
@camtheman256
Copy link
Author

The builtin templates are here, which can be useful for developing on top of: https://github.com/jj-vcs/jj/blob/main/cli/src/config/templates.toml

Could be cool to contribute a "vcs_prompt" template upstream, so then we can just use jj log -T vcs_prompt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment