-
Notifications
You must be signed in to change notification settings - Fork 404
Starship
Jo Liss edited this page Feb 19, 2025
·
7 revisions
https://starship.rs/ is a cross-shell prompt.
For some info about the jj change you are currently at you can use:
[custom.jj]
command = '''
jj log -r@ -n1 --ignore-working-copy --no-graph --color always -T '
separate(" ",
bookmarks.map(|x| if(
x.name().substr(0, 10).starts_with(x.name()),
x.name().substr(0, 10),
x.name().substr(0, 9) ++ "…")
).join(" "),
tags.map(|x| if(
x.name().substr(0, 10).starts_with(x.name()),
x.name().substr(0, 10),
x.name().substr(0, 9) ++ "…")
).join(" "),
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) ++ "…"
)
),
if(conflict, "conflict"),
if(divergent, "divergent"),
if(hidden, "hidden"),
)
'
'''
when = "jj root"
symbol = "jj"
[custom.jjstate]
when = "jj root"
command = '''
jj log -r@ -n1 --no-graph -T "" --stat | tail -n1 | sd "(\d+) files? changed, (\d+) insertions?\(\+\), (\d+) deletions?\(-\)" ' ${1}m ${2}+ ${3}-' | sd " 0." ""
'''
This is partially inspired by the Fish Shell prompt example. This is a quick solution, feel free to improve on it and share your improvements.
Example screenshot:
![image](https://private-user-images.githubusercontent.com/524783/414778027-b12e8076-4745-4fe4-a860-65b9ddbc48b9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5ODI0NDEsIm5iZiI6MTczOTk4MjE0MSwicGF0aCI6Ii81MjQ3ODMvNDE0Nzc4MDI3LWIxMmU4MDc2LTQ3NDUtNGZlNC1hODYwLTY1YjlkZGJjNDhiOS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxOVQxNjIyMjFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jZmMyMzNkNDRkOWQ5ODNiNGI1ODI4YjU5MWY0Zjg0Y2IzOTYyOGEyNmMwNjZiYzJjNzJhZGQ5MGVlYjA4MDQ5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.UfXS09_ENqnmSIHnZI-J7lEEfwZWF7sjoinnFtIllbE)
Here's an alternate configuration. Importantly, by setting when
to true and combining jj root && jj log ...
directly into command
, we can move from two (very expensive!) shell invocations down to one.
# custom module for jj status
[custom.jj]
ignore_timeout = true
description = "current jj status"
symbol = ""
when = true
command = '''
jj root > /dev/null && jj log --revisions @ --no-graph --ignore-working-copy --color always --limit 1 --template '
separate(" ",
"🥋",
change_id.shortest(4),
bookmarks,
"|",
concat(
if(conflict, "💥"),
if(divergent, "🚧"),
if(hidden, "👻"),
if(immutable, "🔒"),
),
raw_escape_sequence("\x1b[1;32m") ++ if(empty, "(empty)"),
raw_escape_sequence("\x1b[1;32m") ++ if(description.first_line().len() == 0,
"(no description set)",
if(description.first_line().substr(0, 29) == description.first_line(),
description.first_line(),
description.first_line().substr(0, 29) ++ "…",
)
) ++ raw_escape_sequence("\x1b[0m"),
)
'
'''
# disable git modules
[git_state]
disabled = true
[git_commit]
disabled = true
[git_metrics]
disabled = true
[git_branch]
disabled = true
# re-enable git_branch as long as we're not in a jj repo
[custom.git_branch]
when = true
command = "jj root >/dev/null 2>&1 || starship module git_branch"
description = "Only show git_branch if we're not in a jj repo"
Example screenshot:
![image](https://private-user-images.githubusercontent.com/524783/414778784-2b8c84f8-c0f8-4871-bd48-eda8df65ea88.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5ODI0NDEsIm5iZiI6MTczOTk4MjE0MSwicGF0aCI6Ii81MjQ3ODMvNDE0Nzc4Nzg0LTJiOGM4NGY4LWMwZjgtNDg3MS1iZDQ4LWVkYThkZjY1ZWE4OC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxOVQxNjIyMjFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02YWMwMjRjMWM0MzhlZGI2MGYxM2VhYzc0MGU3MDhkNmMxZGU1ODQzOGY1OWZlYmQxZmIzM2IyN2U0YmY4OTM0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.YSQvpce8naE48TFOXaVU0lXwa9OCbBETiLvuEDAbedY)