Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fish completions #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ HOOKSDIR ?= $(PREFIX)/share/aurpublish
ZCOMPDIR ?= $(PREFIX)/share/zsh/site-functions
MANS = doc/aurpublish.1
BASHCOMPDIR ?= $(shell pkg-config bash-completion --variable=completionsdir || echo '/usr/share/bash-completion/completions')
FISHCOMPDIR ?= $(PREFIX)/share/fish/vendor_completions.d

edit = sed -e 's|@HOOKSDIR@|$(HOOKSDIR)|g'

Expand All @@ -26,8 +27,10 @@ install: all
install -m755 *.hook '$(DESTDIR)$(HOOKSDIR)/'
install -dm755 '$(DESTDIR)$(ZCOMPDIR)'
install -dm755 '$(DESTDIR)$(BASHCOMPDIR)'
install -dm755 '$(DESTDIR)$(FISHCOMPDIR)'
install -m644 completion/$(NAME).zsh '$(DESTDIR)$(ZCOMPDIR)/_$(NAME)'
install -m644 completion/$(NAME).bash '$(DESTDIR)$(BASHCOMPDIR)/$(NAME)'
install -m644 completion/$(NAME).fish '$(DESTDIR)$(FISHCOMPDIR)/$(NAME).fish'
for manfile in $(MANS); do \
install -Dm644 $$manfile -t $(DESTDIR)$(PREFIX)/share/man/man$${manfile##*.}; \
done
27 changes: 27 additions & 0 deletions completion/aurpublish.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# aurpublish

set -l local_pkgs "(git ls-tree -d --name-only HEAD :/ 2>/dev/null)"

set -l all_pkgs
# Try to get a pkg list from AUR helpers, otherwise ask pacman for foreign packages
if type -q 'yay'
set all_pkgs "(yay -Pc)"
else if type -q 'paru'
set all_pkgs "(paru -Pc | string replace ' ' \t)"
else
set all_pkgs "(pacman -Qqm)"
end

set -l subcmds setup log
complete -c aurpublish -n "not __fish_seen_subcommand_from $subcmds" -xa $local_pkgs -d 'Push a subtree to the AUR'
complete -c aurpublish -n "not __fish_seen_subcommand_from $subcmds" -a setup \
-d 'Install githooks to the repository'
complete -c aurpublish -n "__fish_seen_subcommand_from setup" -x
complete -c aurpublish -n "not __fish_seen_subcommand_from $subcmds" -a log \
-d 'Wrapper for `git log`, substituting a package subtree for the revision/branch.'
complete -c aurpublish -n "__fish_seen_subcommand_from log" -xa $local_pkgs

complete -c aurpublish -s p -ra $all_pkgs -d 'Instead of publishing, pull changes from the AUR'
complete -c aurpublish -s s -l speedup -d 'Speedup future publishing by recording the subtree history during a push'
complete -c aurpublish -s h -l help -d 'Prints a usage page'