Created
December 3, 2024 19:51
-
-
Save fzakaria/25a3e5cd0005d96e9a69a3496ecbee7f to your computer and use it in GitHub Desktop.
A simple fzf powered jujutsu command that shows some possible revsets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Motivation
I had trouble remembering revsets and wanted to collect powerful revsets.
Once
jj util exec
is launched this can be powered byjj
directly via an alias likejj rlog