Two useful aliases for use with JJ
Everyone will have the jj tug alias defined in their list of aliases in
their jj config.
I would like to share two that I think are quite nifty and useful!
JJ Aliases
But I wanted to share two based on my month's use of JJ. The one thing that I do quite often is checkout other people's branches (bookmarks sorry 😉) to help them out. So my usual flow would have been to run something like...
# Read the results and then run
# Do the review
# or
That is a bit of a faff so I just aliased these.
Note: You do need fzf installed in my version so I can quickly fuzzy find the bookmark name. But who doesn't have
fzfinstalled by now?!
[]
= ["util", "exec", "--", 'sh', '-euc', '''
B=$(jj bookmark list --all -T 'name ++ "\n"' | sort | uniq | fzf)
if [ -n "$B" ]; then
jj b track --remote=origin "$B" > /dev/null 2>&1
echo "Tracking: $B"
jj b l --tracked
fi
''' ]
= ["util", "exec", "--", 'sh', '-euc', '''
B=$(jj b l --tracked -T 'name ++ "\n"' | sort | uniq | fzf)
if [ -n "$B" ]; then
jj b untrack --remote=origin "$B" > /dev/null 2>&1
echo "Untracked: $B"
jj b l --tracked
fi
''' ]
= ["util", "exec", "--", 'sh', '-euc', '''
B=$(jj b l --tracked -T 'name ++ "\n"' | sort | uniq | fzf)
if [ -n "$B" ]; then
jj b forget "$B" > /dev/null 2>&1
echo "Forgot: $B"
jj b l --tracked
fi
''' ]
These aliases will run the first command, sort the output, remove duplicates, pipe it to fzf
for you to select from, and then run the second command with your selection.
Good luck on your jj Journey!
