Skip to content

Commit

Permalink
Merge pull request #153 from MarkusGordathian/shell-completions
Browse files Browse the repository at this point in the history
Add bash completions
  • Loading branch information
acrisci committed Oct 22, 2019
2 parents 17f774e + 1e2fd80 commit d4e13ca
Showing 1 changed file with 61 additions and 0 deletions.
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

0 comments on commit d4e13ca

Please sign in to comment.