Add basic bash completion

This commit is contained in:
Adrian L. Shaw 2020-10-04 19:35:05 +01:00
parent 7ab2c9dcc1
commit dcd9fbfaf9
2 changed files with 25 additions and 0 deletions

23
legendary/bash/legendary Normal file
View file

@ -0,0 +1,23 @@
_cmds()
{
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ${cur} == * ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
# Add main commands
opts=$(legendary --help | grep "{*}" | tr '{|}|,' ' ' | head --lines=1)
opts=${opts##*( )}
# Add dashed commands
opts="$opts $(legendary --help | grep "\-\-" | awk '{ printf $1 " " $2 "\n" }' | tr '\n|,' ' ')"
complete -F _cmds legendary

View file

@ -38,6 +38,8 @@ setup(
'setuptools',
'wheel'
],
data_files=[
('/etc/bash_completion.d/', ['legendary/bash/legendary'])],
url='https://github.com/derrod/legendary',
description='Free and open-source replacement for the Epic Games Launcher application',
long_description=long_description,