From dcd9fbfaf95c6b1f289783d99f132522ac968f33 Mon Sep 17 00:00:00 2001 From: "Adrian L. Shaw" Date: Sun, 4 Oct 2020 19:35:05 +0100 Subject: [PATCH] Add basic bash completion --- legendary/bash/legendary | 23 +++++++++++++++++++++++ setup.py | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 legendary/bash/legendary diff --git a/legendary/bash/legendary b/legendary/bash/legendary new file mode 100644 index 0000000..e685bc0 --- /dev/null +++ b/legendary/bash/legendary @@ -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 diff --git a/setup.py b/setup.py index be343fd..c25f942 100644 --- a/setup.py +++ b/setup.py @@ -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,