From ed4ff15f96734993e2501528699ae4ae842557be Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 26 Apr 2020 23:32:13 +0200 Subject: [PATCH] Update bash-completion --- .bash-completion | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.bash-completion b/.bash-completion index 9df439b..23060b5 100644 --- a/.bash-completion +++ b/.bash-completion @@ -1,11 +1,14 @@ _ghcup() { - local cur - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - if [[ ${#COMP_WORDS[*]} -le 2 ]]; then - COMPREPLY=($(compgen -W "$(ghcup --list-commands)" -- $cur)) - fi - return 0 -} && -complete -F _ghcup ghcup + local CMDLINE + local IFS=$'\n' + CMDLINE=(--bash-completion-index $COMP_CWORD) + + for arg in ${COMP_WORDS[@]}; do + CMDLINE=(${CMDLINE[@]} --bash-completion-word $arg) + done + + COMPREPLY=( $(ghcup "${CMDLINE[@]}") ) +} + +complete -o filenames -F _ghcup ghcup