zsh: automatic jj abbreviations
This commit is contained in:
parent
f8d1cf1a57
commit
1ba2eef66b
3 changed files with 35 additions and 8 deletions
|
@ -1,6 +0,0 @@
|
|||
abbr add -S --force "c"="jj commit"
|
||||
abbr add -S --force "new"="jj new main"
|
||||
abbr add -S --force "p"="jj git push"
|
||||
abbr add -S --force "s"="jj status"
|
||||
abbr add -S --force "sl"="jj log --ignore-working-copy"
|
||||
abbr add -S --force "d"="jj show"
|
|
@ -1,4 +1,4 @@
|
|||
abbr "abbr-jj"="source ~/.config/zsh-abbr/abbr-jj"
|
||||
abbr "b"="git branch -va"
|
||||
abbr "c"="git commit"
|
||||
abbr "d"="git diff --stat -p -C --color-words"
|
||||
abbr "g"="git"
|
||||
|
@ -6,4 +6,6 @@ abbr "k"="kubectl"
|
|||
abbr "new"="git checkout --detach main"
|
||||
abbr "p"="git push"
|
||||
abbr "s"="git status"
|
||||
abbr "sl"="git sl"
|
||||
abbr "sl"="git branchless smartlog"
|
||||
abbr "sw"="git branchless switch --interactive"
|
||||
abbr "sy"="git sync --pull"
|
||||
|
|
31
.zshrc
31
.zshrc
|
@ -145,6 +145,37 @@ rg() {
|
|||
/usr/bin/rg -p "$@" | bat
|
||||
}
|
||||
|
||||
|
||||
## Jujutsu
|
||||
jj_chpwd() {
|
||||
_state="$JJ_REPO"
|
||||
JJ_REPO=$(jj workspace root --ignore-working-copy 2>/dev/null)
|
||||
if [[ "$JJ_REPO" == "$_state" ]]; then
|
||||
return
|
||||
fi
|
||||
if [[ -n "$JJ_REPO" ]]; then
|
||||
abbr add -S --force "b"="jj branch list"
|
||||
abbr add -S --force "c"="jj commit"
|
||||
abbr add -S --force "d"="jj show"
|
||||
abbr add -S --force "new"="jj new main"
|
||||
abbr add -S --force "p"="jj git push"
|
||||
abbr add -S --force "s"="jj status"
|
||||
abbr add -S --force "sl"="jj log --ignore-working-copy"
|
||||
abbr add -S --force "sy"="jj git fetch"
|
||||
else
|
||||
abbr erase -S b
|
||||
abbr erase -S c
|
||||
abbr erase -S d
|
||||
abbr erase -S new
|
||||
abbr erase -S p
|
||||
abbr erase -S s
|
||||
abbr erase -S sl
|
||||
abbr erase -S sy
|
||||
fi
|
||||
}
|
||||
chpwd_functions+=jj_chpwd
|
||||
|
||||
|
||||
## Prompt
|
||||
|
||||
prompt_chpwd() {
|
||||
|
|
Loading…
Reference in a new issue