jjj
106 points by op
106 points by op
I could not pass up this opportunity to do the Obvious Funny Thing, so: https://arch1t3cht.org/blog/jjjj/
On a more constructive note: This is a very neat tool, though I had to replace $@ with ${@:2} to prevent the command from being added twice as an argument.
aha, that is lovely. i do want to eventually add fzf's multiselect to pass multiple revs to commands.
though I had to replace $@ ...
oh dear! i think i dropped a shift when writing the code in the blog post. that should fix this.
I don't use jj, but isn't the problem here over-reliance on anonymous branches? Wouldn't it be easier to name your branches than having to write tooling to look at commits to manage to switch back to a desired branch? Surely a good-enough name can't be that hard to determine? Issue tracker ids, or exception tracker identifiers, make perfectly serviceable branch names. Am I missing something?
I don't use jj, but isn't the problem here over-reliance on anonymous branches? [...] Am I missing something?
Git, for example, has many places where "commit/diff"-like things can be stored: commits, stashes, edit-rebases, the staging index.
JJ reduced this to just commits.
The net result is that doing stash/edit-rebases/staging in JJ results in lots of anonymous commits.
This raises the problem of needing to copy/paste IDs (as op has found), but in return everything being a commit is simple/powerful, because every operation becomes an operation on a commit, with the few set of commands to do that.
I don't wonder "what sequence of commands/flags do I need to take my stash and then rebase it onto upstream's master", I already know it's just a rebase from one commit to another.
Nice! I do much more commit graph manipulation in jj, so it's handy to have this.
jj "$cmd" -r "$rev" "$@"
Here's a version that selects and inserts a jj commit ID at the current point. This allows it to be used commands that don't use -r, e.g. jj interdiff --from foo --to bar:
_fzf_insert_jj_commit() {
local selected rev
selected=$(
jj log -r 'all()' --color=always \
| fzf \
--min-height=15 \
--cycle \
--ansi \
--prompt "jj rev> "
)
rev=$(echo "$selected" | awk '{for(i=1;i<=NF;i++) if(length($i)>=7){print $i; exit}}')
READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}${rev}${READLINE_LINE:$READLINE_POINT}"
READLINE_POINT=$((READLINE_POINT + ${#rev}))
}
bind -x '"\C-j": _fzf_insert_jj_commit'
I use neovim as a daily driver and have telescope wrappers that help me navigate jj log ^1.
fzf is very amazing. Highly worth looking at the docs for it, you can configure so much UI into it. I'm fairly convinced you probably could put even more of jjj just into fzf command params itself