git-revise
git-revise copied to clipboard
Fish shell completions contribution
I started with the completions Fish generates from the man page and added completion for commits.
For some reason I couldn't get keep-order to work so using commit hashes was impractical, so I went with HEAD~n syntax instead.
# git-revise
# Modified after autogenerated from man page /usr/share/man/man1/git-revise.1.gz
function __fish_complete_refs
echo HEAD\t
git branch --all --format='%(refname:short)'\t
end
function __fish_complete_commits
set commits (git rev-list --count HEAD)
set n (math 'min('$commits' - 1, 10)')
for i in (seq -w 0 $n)
set r HEAD~$i
echo $r\t(git log -1 --oneline --format='%d %s' $r)
end
end
complete -c git-revise -e
complete -c git-revise -f
complete -c git-revise -s a -l all -d 'Stage changes to tracked files before revising'
complete -c git-revise -s p -l patch -d 'Interactively stage hunks from the worktree before revising'
complete -c git-revise -l no-index -d 'Ignore staged changes in the index'
complete -c git-revise -l reauthor -d 'Reset target commit\\(aqs author to the current user'
complete -c git-revise -l ref -d 'Working branch to update; defaults to HEAD' -x -a "(__fish_complete_refs)"
complete -c git-revise -s S -l gpg-sign -l no-gpg-sign -d 'GPG-sign commits. Overrides both the commit. gpgSign and revise'
complete -c git-revise -s i -l interactive -d 'Rather than applying staged changes to <target>, edit a todo list of actions …'
complete -c git-revise -l autosquash -l no-autosquash -d 'Rather than directly applying staged changes to <target>, automatically perfo…'
complete -c git-revise -s c -l cut -d 'Interactively select hunks from <target>'
complete -c git-revise -s e -l edit -d 'After applying staged changes, edit <target>\\(aqs commit message'
complete -c git-revise -s m -l message -d 'Use the given <msg> as the new commit message for <target>' -x
complete -c git-revise -l version -d 'Print version information and exit'
complete -c git-revise -a "(__fish_complete_commits)"
$ diff -u ~/.local/share/fish/generated_completions/git-revise.fish ~/.config/fish/completions/git-revise.fish
--- /home/naftoli/.local/share/fish/generated_completions/git-revise.fish 2022-11-15 22:35:49.556062620 -0500
+++ /home/naftoli/.config/fish/completions/git-revise.fish 2022-11-16 00:09:20.710730827 -0500
@@ -1,15 +1,36 @@
# git-revise
-# Autogenerated from man page /usr/share/man/man1/git-revise.1.gz
+# Modified after autogenerated from man page /usr/share/man/man1/git-revise.1.gz
+
+function __fish_complete_refs
+ echo HEAD\t
+ git branch --all --format='%(refname:short)'\t
+end
+
+function __fish_complete_commits
+ set commits (git rev-list --count HEAD)
+ set n (math 'min('$commits' - 1, 10)')
+ for i in (seq -w 0 $n)
+ set r HEAD~$i
+ echo $r\t(git log -1 --oneline --format='%d %s' $r)
+ end
+end
+
+complete -c git-revise -e
+complete -c git-revise -f
+
complete -c git-revise -s a -l all -d 'Stage changes to tracked files before revising'
complete -c git-revise -s p -l patch -d 'Interactively stage hunks from the worktree before revising'
complete -c git-revise -l no-index -d 'Ignore staged changes in the index'
complete -c git-revise -l reauthor -d 'Reset target commit\\(aqs author to the current user'
-complete -c git-revise -l ref -d 'Working branch to update; defaults to HEAD'
+complete -c git-revise -l ref -d 'Working branch to update; defaults to HEAD' -x -a "(__fish_complete_refs)"
complete -c git-revise -s S -l gpg-sign -l no-gpg-sign -d 'GPG-sign commits. Overrides both the commit. gpgSign and revise'
complete -c git-revise -s i -l interactive -d 'Rather than applying staged changes to <target>, edit a todo list of actions …'
complete -c git-revise -l autosquash -l no-autosquash -d 'Rather than directly applying staged changes to <target>, automatically perfo…'
complete -c git-revise -s c -l cut -d 'Interactively select hunks from <target>'
complete -c git-revise -s e -l edit -d 'After applying staged changes, edit <target>\\(aqs commit message'
-complete -c git-revise -s m -l message -d 'Use the given <msg> as the new commit message for <target>'
+complete -c git-revise -s m -l message -d 'Use the given <msg> as the new commit message for <target>' -x
complete -c git-revise -l version -d 'Print version information and exit'
+complete -c git-revise -a "(__fish_complete_commits)"