summaryrefslogtreecommitdiff
path: root/dot-config
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-10-25 12:56:05 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-10-27 23:06:29 +0800
commit08ad412d7fab4e785e90c7c5ec8b0d9dcbf58cf3 (patch)
treeaea8ca85ed08a7cf993b41c8e6bb1b731369dc9e /dot-config
parentae4f5678844f8d85a5b84fd693d6f4fb630f7bb3 (diff)
jj: prompt
Diffstat (limited to 'dot-config')
-rw-r--r--dot-config/fish/conf.d/jj.abbr.fish18
-rw-r--r--dot-config/fish/functions/fish_jj_prompt.fish41
-rw-r--r--dot-config/fish/functions/fish_prompt.fish11
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)