diff --git a/plugins/jj/README.md b/plugins/jj/README.md index 245ba7032..f6ab30c61 100644 --- a/plugins/jj/README.md +++ b/plugins/jj/README.md @@ -44,9 +44,15 @@ You can find an example Sometimes `jj` can be slower than `git`. -If you feel slowdowns, you can try adding `ZSH_THEME_JJ_IGNORE_WORKING_COPY=1` to your theme, which will add -`--ignore-working-copy` to all calls made to `jj`. The downside here is that your prompt might stay outdated -until the next time `jj` gets a chance to _not_ ignore the working copy. +If you feel slowdowns, consider using the following: + +``` +zstyle :omz:plugins:jj ignore-working-copy yes +``` + +This will add `--ignore-working-copy` to all `jj` commands executed by your prompt. The downside here is that +your prompt might be out-of-sync until the next time `jj` gets a chance to _not_ ignore the working copy (i.e. +you manually run a `jj` command). If you prefer to keep your prompt always up-to-date but still don't want to _feel_ the slowdown, you can make your prompt asynchronous. This plugin doesn't do this automatically so you'd have to hack your theme a bit for diff --git a/plugins/jj/jj.plugin.zsh b/plugins/jj/jj.plugin.zsh index cbe7cee6b..157055ae0 100644 --- a/plugins/jj/jj.plugin.zsh +++ b/plugins/jj/jj.plugin.zsh @@ -3,12 +3,20 @@ if (( ! $+commands[jj] )); then return fi -source <(jj util completion zsh) -compdef _jj jj +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `jj`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_jj" ]]; then + typeset -g -A _comps + autoload -Uz _jj + _comps[jj]=_jj +fi + +jj util completion zsh >| "$ZSH_CACHE_DIR/completions/_jj" &| function __jj_prompt_jj() { - local flags=("--no-pager") - if (( ${ZSH_THEME_JJ_IGNORE_WORKING_COPY:-0} )); then + local -a flags + flags=("--no-pager") + if zstyle -t ':omz:plugins:jj' ignore-working-copy; then flags+=("--ignore-working-copy") fi command jj $flags "$@" @@ -26,14 +34,6 @@ function jj_prompt_template() { } # Aliases (sorted alphabetically) -alias j='jj' -alias jb='jj bookmark' -alias jbc='jj bookmark create' -alias jbd='jj bookmark d' -alias jbl='jj bookmark list' -alias jbr='jj bookmark rename' -alias jbs='jj bookmark set' -alias jbt='jj bookmark track' alias jc='jj commit' alias jcmsg='jj commit --message' alias jd='jj diff' @@ -44,12 +44,10 @@ alias jgcl='jj git clone' alias jgf='jj git fetch' alias jgp='jj git push' alias jl='jj log' +alias jla='jj log -r "all()"' alias jn='jj new' alias jrb='jj rebase' alias jrs='jj restore' alias jrt='cd "$(jj root || echo .)"' -alias js='jj squash' alias jsp='jj split' -alias jsps='jj split --siblings' -alias jst='jj st' -alias jsto='jj squash --into' +alias jsq='jj squash'