Skip to content

Instantly share code, notes, and snippets.

@fzakaria
Created December 3, 2024 19:51
Show Gist options
  • Save fzakaria/25a3e5cd0005d96e9a69a3496ecbee7f to your computer and use it in GitHub Desktop.
Save fzakaria/25a3e5cd0005d96e9a69a3496ecbee7f to your computer and use it in GitHub Desktop.
A simple fzf powered jujutsu command that shows some possible revsets.
#!/bin/bash
# Define revsets and their descriptions
revsets=(
"all()" "All commits of the repository"
"::@" "Show all ancestors"
"remote_bookmarks().." "Show all commits that are not in remote bookmarks"
"mine()" "Commits authored by the current user"
)
# Prepare the input for fzf
fzf_input=""
for ((i = 0; i < ${#revsets[@]}; i += 2)); do
fzf_input+="${revsets[i]}\t${revsets[i+1]}\n"
done
# Pipe revsets into fzf
selected_revset=$(echo -e "$fzf_input" \
| fzf --height 40% --layout reverse --border --with-nth=1 --preview="echo {}" | awk -F'\t' '{print $1}')
# If a revset is selected, run `jj log` with it
if [[ -n "$selected_revset" ]]; then
jj log -r "$selected_revset"
else
echo "No revset selected."
exit 1
fi
@fzakaria
Copy link
Author

fzakaria commented Dec 3, 2024

Motivation
I had trouble remembering revsets and wanted to collect powerful revsets.
Once jj util exec is launched this can be powered by jj directly via an alias like jj rlog

Screenshot 2024-12-03 at 11 51 56 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment