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

Add shell completions for bash, zsh and fish #50

Merged
merged 1 commit into from
Apr 13, 2024
Merged
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
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ install:
# Install the main script
install -Dm 755 "src/script/${pkgname}.sh" "${DESTDIR}${PREFIX}/bin/${pkgname}"

# Install shell completions
install -Dm 644 "res/completions/${pkgname}.bash" "${DESTDIR}${PREFIX}/share/bash-completion/completions/${pkgname}"
install -Dm 644 "res/completions/${pkgname}.zsh" "${DESTDIR}${PREFIX}/share/zsh/site-functions/_${pkgname}"
install -Dm 644 "res/completions/${pkgname}.fish" "${DESTDIR}${PREFIX}/share/fish/vendor_completions.d/${pkgname}.fish"

# Archive and install man pages
gzip -c "doc/man/${pkgname}.1" > "${pkgname}.1.gz"
install -Dm 644 "${pkgname}.1.gz" "${DESTDIR}${PREFIX}/share/man/man1/${pkgname}.1.gz"
Expand Down
13 changes: 13 additions & 0 deletions res/completions/zaman.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
_zaman() {
local arg="${2}"
local -a opts
opts=('-m --menu
-o --output
-O --save
-h --help
-V --version')

COMPREPLY=( $(compgen -W "${opts[*]}" -- "${arg}") )
}

complete -F _zaman zaman
7 changes: 7 additions & 0 deletions res/completions/zaman.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
complete -c zaman -f

complete -c zaman -s m -l menu -d 'Print a menu via rofi or dmenu that lists every man pages to choose from (default operation)'
complete -c zaman -s o -l output -d '(Args <man page> <file>) Save <man page> into the <file> PDF file'
complete -c zaman -s O -l save -d '(Arg <man page>) Save <man page> into the "man_<man page>.pdf" file in the current directory'
complete -c zaman -s h -l help -d 'Display the help message'
complete -c zaman -s V -l version -d 'Display version information'
12 changes: 12 additions & 0 deletions res/completions/zaman.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#compdef zaman

local -a opts
opts=(
{-m,--menu}'[Print a menu via rofi or dmenu that lists every man pages to choose from (default operation)]'
{-o,--output}'[(Args <man page> <file>) Save <man page> into the <file> PDF file]'
{-O,--save}'[(Arg <man page>) Save <man page> into the "man_<man page>.pdf" file in the current directory]'
{-h,--help}'[Display the help message]'
{-V,--version}'[Display version information]'
)

_arguments $opts