diff --git a/fish/.config/fish/functions/fish_jj_prompt.fish b/fish/.config/fish/functions/fish_jj_prompt.fish new file mode 100644 index 0000000..5905eff --- /dev/null +++ b/fish/.config/fish/functions/fish_jj_prompt.fish @@ -0,0 +1,41 @@ +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) ++ "…" + ) + ), + "(no description set)" + ), + change_id.shortest(), + commit_id.shortest(), + if(conflict, "(conflict)"), + if(empty, "(empty)"), + if(divergent, "(divergent)"), + if(hidden, "(hidden)"), + ) + ) + ' +end diff --git a/fish/.config/fish/functions/fish_prompt.fish b/fish/.config/fish/functions/fish_prompt.fish index 790647c..646cbef 100644 --- a/fish/.config/fish/functions/fish_prompt.fish +++ b/fish/.config/fish/functions/fish_prompt.fish @@ -33,11 +33,11 @@ end function fish_prompt --description 'Write out the prompt' set -l last_status $status - set -l _pwd (set_color $fish_color_cwd) (prompt_pwd) + set -l _pwd (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) echo -n -s (__bcarlin_prompt_venv) echo -n -s "$USER" @ (prompt_hostname) ' ' $_pwd - echo -n -s (fish_git_prompt) + echo -n -s (fish_vcs_prompt) if test $last_status -ne 0 echo -n -s (set_color red --bold)" [$last_status]" (set_color normal) end diff --git a/fish/.config/fish/functions/fish_vcs_prompt.fish b/fish/.config/fish/functions/fish_vcs_prompt.fish new file mode 100644 index 0000000..216244c --- /dev/null +++ b/fish/.config/fish/functions/fish_vcs_prompt.fish @@ -0,0 +1,12 @@ +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_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. + # To enable it uncomment it. + # You can also only use it in specific directories by checking $PWD. + # or fish_svn_prompt +end