dotfiles/vcs/jj/config/sh/alias.d/jj.sh
Marty Oehme 44b33fcc41
jj: Adopt new default revset aliases
This commit changes the way I display my jj logs a little. We
distinguish between 3 styles now

- the 'stack()': short and to the point, only ancestor commits from the
  last non-mutable one onwards
- the 'recent()': the previously default view over ancestor commits or
  any other head nodes (i.e. any branches) that are from me,
  with a few commits leading up to them visible.
- the 'all()': the traditional 'show everything' summation for finding
  very specific commits or getting a macro-scale overview of the history

Basically, only the 'stack()' view was added - but it is now the new
default for the default command and the previous 'default' has been
renamed to 'recent()'.

This is mirrored in the shell aliases: all the `jl`, `jlo`, `jloo`
aliases use the 'recents()' view. The capital versions (`JL` and the
like) are not affected as as they keep showing the 'all()' view.
Importantly, the `j` base command uses the 'stack()' view, however.

Lastly, we extract the aliases to find `WIP:` commits and `PRIVATE:`
commits into actual jj revset aliases and call them from our shell
aliases. The functionality does not change, though we now have an
additional alias for finding specifically the latter commits with `jlfp`
('jj log find private').
2025-06-21 12:13:24 +02:00

85 lines
2.3 KiB
Bash

#!/usr/bin/env sh
if ! exist jj; then
return 1
fi
alias j="jj"
if exist lazyjj; then
alias lj="lazyjj"
fi
alias jn="jj new"
alias jna="jj new -A@"
alias jnb="jj new -B@"
alias jds="jj describe"
alias jc="jj commit"
# finding out the current snapshot
alias js="jj status"
alias jw="jj show"
alias jd="jj diff"
# for describe-and-edit workflows
# https://steveklabnik.github.io/jujutsu-tutorial/real-world-workflows/the-edit-workflow.html
alias je="jj edit"
alias jen="jj next --edit"
alias jep="jj prev --edit"
alias jenn="jj next"
alias jepp="jj prev"
# edit the 'newest' head descendant of current working copy
# usually means 'get me to head of current branch'
alias jed="jj edit -r 'latest(heads(descendants(@)))'"
# go to the newest head of the trunk branch
alias jet="jj edit -r 'latest(heads(descendants(trunk())))'"
# simply go to the newest commit, i.e. our last change committed
alias jel="jj edit -r 'latest(all())'"
# for squash-and-go workflows
# https://steveklabnik.github.io/jujutsu-tutorial/real-world-workflows/the-squash-workflow.html
alias jss="jj squash"
alias jsi="jj squash --interactive"
# oops buttons
alias ju="jj undo"
# allows you to split the current change into multiple
alias ji="jj split"
# quickly get rid of a change
alias jab="jj abandon"
# revset info
alias J="jj log -r 'all()'" # mirror default command being log
alias jl="jj log -T builtin_log_oneline -r 'recent()'"
alias JL="jj log -T builtin_log_oneline -r 'all()'"
alias jlo="jj log --summary -T builtin_log_compact_full_description -r 'recent()'"
alias JLO="jj log --summary -T builtin_log_compact_full_description -r 'all()'"
alias jloo="jj log --patch -r 'recent()'"
alias JLOO="jj log --patch -r 'all()'"
alias jol="jj op log"
jlf() {
jj log -r "description(substring-i:\"$*\")"
}
jlof() {
jj log --summary -r "description(substring-i:\"$*\")"
}
jloof() {
jj log --patch -r "description(substring-i:\"$*\")"
}
alias jlfw='jj log -r "wip()"'
alias jlfp='jj log -r "private()"'
# show branches (i.e. head commits) w a couple previous commits
alias jh="jj log -r 'ancestors(heads(all()), 3)'"
alias jrb="jj rebase"
# 'branching' bookmark work
alias jb="jj bookmark"
alias jbl="jj bookmark list"
jbm() { # set 'main' bookmark to current or given change
jj bookmark set -r "${1:-@}" main
}
# remote work
alias jrv="jj git remote list"
alias jp="jj git push"