start a jj segment

This commit is contained in:
Daylin Morgan 2024-11-18 17:39:06 -06:00
parent b22cc12a57
commit 3b6e09c17f
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -35,6 +35,7 @@
os_icon # os identifier os_icon # os identifier
dir # current directory dir # current directory
vcs # git status vcs # git status
jj # jujutsu status
# =========================[ Line #2 ]========================= # =========================[ Line #2 ]=========================
newline # \n newline # \n
prompt_char # prompt symbol prompt_char # prompt symbol
@ -372,6 +373,11 @@
function my_git_formatter() { function my_git_formatter() {
emulate -L zsh emulate -L zsh
if ! [[ $(_p9k_upglob '.jj/') ]] then
typeset -g my_git_format=""
return
fi
if [[ -n $P9K_CONTENT ]]; then if [[ -n $P9K_CONTENT ]]; then
# If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from
# gitstatus plugin). VCS_STATUS_* parameters are not available in this case. # gitstatus plugin). VCS_STATUS_* parameters are not available in this case.
@ -471,7 +477,7 @@
# in this case. # in this case.
(( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}" (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}"
typeset -g my_git_format=$res typeset -g my_git_format="${res}"
} }
functions -M my_git_formatter 2>/dev/null functions -M my_git_formatter 2>/dev/null
@ -1658,6 +1664,25 @@
p10k segment -f 2 -i '⭐' -t 'hello, %n' p10k segment -f 2 -i '⭐' -t 'hello, %n'
} }
function prompt_jj() {
# how to make this work like git?
_p9k_upglob '.jj' && return
local templ='
concat(
separate(" ",
format_short_change_id_with_hidden_and_divergent_info(self),
format_short_commit_id(commit_id),
if(conflict, label("conflict", "conflict")),
if(empty, label("empty", "(empty)")),
if(description, description.first_line(),label(if(empty, "empty"), description_placeholder),
)))'
local jj_status="$(jj log -T "$templ" -n 1 --no-graph --color=always)"
p10k segment -t "$jj_status"
}
# User-defined prompt segments may optionally provide an instant_prompt_* function. Its job # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job
# is to generate the prompt segment for display in instant prompt. See # is to generate the prompt segment for display in instant prompt. See
# https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt.