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 bash completions #153

Merged
merged 5 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions completions/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
install_data(sources : 'playerctl.bash', install_dir : '/etc/bash_completion.d')
MarkusG marked this conversation as resolved.
Show resolved Hide resolved
61 changes: 61 additions & 0 deletions completions/playerctl.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash

_playerctl_completions() {
local cur="${COMP_WORDS[$COMP_CWORD]}"
local prev="${COMP_WORDS[$COMP_CWORD - 1]}"
local root_words="
play
pause
play-pause
stop
next
previous
position
volume
status
metadata
open
loop
shuffle
-h --help
-p --player=
-a --all-players
-i --ignore-player=
-f --format
-F --follow
-l --list-all
-v --version"

case $prev in
loop)
COMPREPLY=($(compgen -W "none track playlist" -- "$cur"))
return 0
;;
shuffle)
COMPREPLY=($(compgen -W "on off" -- "$cur"))
return 0
;;
-p|--player=|-i|--ignore-player=)
COMPREPLY=($(compgen -W "$(playerctl --list-all)" -- "$cur"))
return 0
;;
-f|--format)
COMPREPLY=()
return 0
;;
open)
compopt -o default
COMPREPLY=()
;;
position|volume|metadata)
COMPREPLY=()
return 0
;;
*)
COMPREPLY=($(compgen -W "$root_words" -- "$cur"))
return 0
;;
esac
}

complete -F _playerctl_completions playerctl
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ glib_dep = dependency('glib-2.0')

subdir('playerctl')
subdir('doc')
subdir('completions')