diff options
Diffstat (limited to 'dot-config/fish')
| -rw-r--r-- | dot-config/fish/conf.d/jj.abbr.fish | 18 | ||||
| -rw-r--r-- | dot-config/fish/functions/fish_jj_prompt.fish | 41 | ||||
| -rw-r--r-- | dot-config/fish/functions/fish_prompt.fish | 11 |
3 files changed, 67 insertions, 3 deletions
diff --git a/dot-config/fish/conf.d/jj.abbr.fish b/dot-config/fish/conf.d/jj.abbr.fish new file mode 100644 index 00000000..3611d60c --- /dev/null +++ b/dot-config/fish/conf.d/jj.abbr.fish @@ -0,0 +1,18 @@ +abbr -a g jj +abbr -a gp 'jj git push --tracked' +abbr -a gpd 'jj git push --deleted' +abbr -a gs 'jj st' +abbr -a gl 'jj log' +abbr -a gc 'jj commit -m' +abbr -a gb 'jj bookmark' +abbr -a gi 'jj --ignore-immutable' +abbr -a gr 'jj git remote' +function gd + if test (count $argv) -ge 2 + jj diff --from $argv[1] --to $argv[2] + else if test (count $argv) -ge 1 + jj diff --from $argv[1] --to @ + else + jj diff --from @- --to @ + end +end diff --git a/dot-config/fish/functions/fish_jj_prompt.fish b/dot-config/fish/functions/fish_jj_prompt.fish new file mode 100644 index 00000000..87dfc3ec --- /dev/null +++ b/dot-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) ++ "…" + ) + ), + label(if(empty, "empty"), description_placeholder) + ), + change_id.shortest(), + if(conflict, label("conflict", "(conflict)")), + if(empty, label("empty", "(empty)")), + if(divergent, "(divergent)"), + if(hidden, "(hidden)"), + ) + ) + ' +end +# commit_id.shortest(), diff --git a/dot-config/fish/functions/fish_prompt.fish b/dot-config/fish/functions/fish_prompt.fish index be2b7e2e..55f8453e 100644 --- a/dot-config/fish/functions/fish_prompt.fish +++ b/dot-config/fish/functions/fish_prompt.fish @@ -103,9 +103,14 @@ function fish_prompt and _nim_prompt_wrapper $retc '' (path basename "$VIRTUAL_ENV") # git - set -l prompt_git (fish_git_prompt '%s') - test -n "$prompt_git" - and _nim_prompt_wrapper $retc '' $prompt_git + # set -l prompt_git (fish_git_prompt '%s') + # test -n "$prompt_git" + # and _nim_prompt_wrapper $retc '' $prompt_git + + # jj + set -l prompt_jj (fish_jj_prompt '%s') + test -n "$prompt_jj" + and _nim_prompt_wrapper $retc '' $prompt_jj test ! $prompt_status = 0; and _nim_prompt_wrapper $retc '' (fish_status_to_signal $prompt_status) |
