diff --git a/.vscode/settings.json b/.vscode/settings.json index 8b88530..67ec1e8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,7 +23,8 @@ "**/*.txt", "**/*.mdown", "**/*.md", - "**/*.container", + "**/*.recipe", + "**/*.completion", "**/miaou-*", ], "todohighlight.enableDiagnostics": true, diff --git a/lib/miaou.completion b/lib/miaou.completion index 654d894..320aebe 100644 --- a/lib/miaou.completion +++ b/lib/miaou.completion @@ -62,16 +62,30 @@ function _miaou_exec() { if ((COMP_CWORD == 3)); then # command or file from inside container # echo -e "\nCOMMAND or FILE from CONTAINER\n" >&2 - COMPREPLY=($( + + COMPREPLY_COMMANDS=($( incus exec "$container" -- bash << EOF bind -f /etc/inputrc 2>/dev/null source /etc/bash_completion compgen -c -- "$cur" +EOF + )) + COMPREPLY_FILES=($( + incus exec "$container" -- bash << EOF + bind -f /etc/inputrc 2>/dev/null + source /etc/bash_completion compgen -f -- "$cur" EOF )) - compopt -o filenames - compopt -o nospace + + COMPREPLY=(${COMPREPLY_COMMANDS[@]} ${COMPREPLY_FILES[@]}) + if [[ ${#COMPREPLY_FILES[@]} -gt 0 ]]; then + compopt -o filenames + compopt -o nospace + fi + + # echo -e "\nCOMPREPLY=( ${COMPREPLY[@]} ) FILES=${#COMPREPLY_FILES[@]}\n" >&2 + return fi