feat(fish): add support for jj in the prompt
This commit is contained in:
parent
7a123e0341
commit
d790c59b6a
3 changed files with 55 additions and 2 deletions
41
fish/.config/fish/functions/fish_jj_prompt.fish
Normal file
41
fish/.config/fish/functions/fish_jj_prompt.fish
Normal file
|
@ -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
|
|
@ -33,11 +33,11 @@ end
|
||||||
|
|
||||||
function fish_prompt --description 'Write out the prompt'
|
function fish_prompt --description 'Write out the prompt'
|
||||||
set -l last_status $status
|
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 (__bcarlin_prompt_venv)
|
||||||
echo -n -s "$USER" @ (prompt_hostname) ' ' $_pwd
|
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
|
if test $last_status -ne 0
|
||||||
echo -n -s (set_color red --bold)" [$last_status]" (set_color normal)
|
echo -n -s (set_color red --bold)" [$last_status]" (set_color normal)
|
||||||
end
|
end
|
||||||
|
|
12
fish/.config/fish/functions/fish_vcs_prompt.fish
Normal file
12
fish/.config/fish/functions/fish_vcs_prompt.fish
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue