From 0debddc9e505e6dac25f328ef9c8037e81a9202e Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 19 Nov 2024 09:43:29 +0100 Subject: [PATCH] Add a simple fish_jj_prompt jj is often colocated with Git so the Git prompt also works, but jj is always in a detached HEAD state, which is atypical for Git. The jj prompt improves things by showing the revision ID which is usually more useful than the commit ID. This prompt is mostly adapted from the defaults for "jj log -r @". Showing conflicting/empty commits seems useful. Also perhaps bookmarks and tags, not sure. The main problem with this prompt is that due to --ignore-working-copy, the information may be stale. That will be rectified after every jj command, so hopefully this doesn't cause issues. --- share/functions/fish_jj_prompt.fish | 14 ++++++++++++++ share/functions/fish_vcs_prompt.fish | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 share/functions/fish_jj_prompt.fish diff --git a/share/functions/fish_jj_prompt.fish b/share/functions/fish_jj_prompt.fish new file mode 100644 index 000000000..e3b8eaf17 --- /dev/null +++ b/share/functions/fish_jj_prompt.fish @@ -0,0 +1,14 @@ +function fish_jj_prompt + jj log 2>/dev/null --no-graph --ignore-working-copy --color=always --revisions @ \ + --template ' + concat( + " ", + separate(" ", + format_short_change_id_with_hidden_and_divergent_info(self), + bookmarks, + tags, + if(conflict, label("conflict", "×")), + if(empty, label("empty", "(empty)")) + ), + )' +end diff --git a/share/functions/fish_vcs_prompt.fish b/share/functions/fish_vcs_prompt.fish index b3a42cdb6..216244cc8 100644 --- a/share/functions/fish_vcs_prompt.fish +++ b/share/functions/fish_vcs_prompt.fish @@ -1,7 +1,8 @@ function fish_vcs_prompt --description "Print all vcs prompts" # If a prompt succeeded, we assume that it's printed the correct info. # This is so we don't try svn if git already worked. - fish_git_prompt $argv + fish_jj_prompt $argv + or fish_git_prompt $argv or fish_hg_prompt $argv or fish_fossil_prompt $argv # The svn prompt is disabled by default because it's quite slow on common svn repositories.