jjj

106 points by op


arch1t3cht

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.

stig

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?

tuxes

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'
whereistejas

I use neovim as a daily driver and have telescope wrappers that help me navigate jj log ^1.