diff options
author | Alexander Larsson <alexl@redhat.com> | 2015-09-24 12:34:54 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2015-09-24 21:36:35 +0200 |
commit | 97ef439f59f4636071ddf3f58737bafb90d425f6 (patch) | |
tree | fb60691822b09689d50184dcb9cd6fcc265996bb /completion | |
parent | afda9d54c4e057af1c870e0bbc1bee8887411e6d (diff) | |
download | xdg-app-97ef439f59f4636071ddf3f58737bafb90d425f6.tar.gz |
bash_completion: Properly list apps when completing "run"
Diffstat (limited to 'completion')
-rwxr-xr-x | completion/xdg-app | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/completion/xdg-app b/completion/xdg-app index 3adb211..8899ee6 100755 --- a/completion/xdg-app +++ b/completion/xdg-app @@ -28,6 +28,7 @@ _xdg-app() { [PERMS]='run override build build-finish' [UNINSTALL]='uninstall-runtime uninstall-app' [ARCH]='build-init install-runtime install-app run uninstall-runtime uninstall-app update-runtime update-app make-app-current' + [USER_AND_SYSTEM]='run list-remotes list-apps list-runtimes' ) local -A OPTS=( @@ -50,10 +51,35 @@ _xdg-app() { [ARG]='--arch --command --branch --var --share --unshare --socket --nosocket --device --nodevice --subject --body --title --runtime --filesystem' ) + for ((i=0; i < COMP_CWORD; i++)); do + if [[ "${COMP_WORDS[i]}" = -* ]]; then + continue + fi + if __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then + continue + fi + if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} && + test -z $first_verb; then + first_verb=${COMP_WORDS[i]} + fi + done + if __contains_word "--user" ${COMP_WORDS[*]}; then - mode=--user + if __contains_word "--system" ${COMP_WORDS[*]}; then + mode="--user --system" + else + mode="--user" + fi else + if __contains_word "--system" ${COMP_WORDS[*]}; then mode=--system + else + if __contains_word "$first_verb" ${VERBS[USER_AND_SYSTEM]}; then + mode="--user --system" + else + mode="--system" + fi + fi fi if __contains_word "$prev" ${OPTS[ARG]}; then |