diff --git a/lib/miaou.completion b/lib/miaou.completion index 0c4b9e3..a3b77e7 100644 --- a/lib/miaou.completion +++ b/lib/miaou.completion @@ -61,13 +61,17 @@ function _miaou_exec() { if ((COMP_CWORD == 3)); then # command or file from inside container - + # echo -e "\nCOMMAND or FILE from CONTAINER\n" >&2 COMPREPLY=($( incus exec "$container" -- bash << EOF - source /etc/bash_completion - compgen -c -- "$cur" + bind -f /etc/inputrc 2>/dev/null + source /etc/bash_completion + compgen -c -- "$cur" + compgen -f -- "$cur" EOF )) + compopt -o filenames + compopt -o nospace return fi @@ -94,19 +98,20 @@ EOF # echo -e "\ncompletion_command $completion_command \nprev=$prev \ncur=$cur \nCOMP_WORDS=(${COMP_WORDS[@]}) \nCOMP_CWORD=$COMP_CWORD \nCOMP_LINE=$COMP_LINE \nCOMP_POINT=$COMP_POINT" >&2 COMPREPLY=($( incus exec "$container" -- bash << EOF - source /etc/bash_completion - for i in /etc/bash_completion.d/*; do source \$i; done - source /usr/share/bash-completion/bash_completion - [[ -f /usr/share/bash-completion/completions/$command ]] && source /usr/share/bash-completion/completions/$command - COMP_WORDS=(${COMP_WORDS[@]}) - COMP_CWORD=$COMP_CWORD - COMP_LINE="$COMP_LINE" - COMP_POINT=$COMP_POINT - COMP_TYPE=9 - COMP_KEY=9 - export COMP_WORDS COMP_CWORD COMP_LINE COMP_POINT COMP_TYPE COMP_KEY - $completion_command 2>/dev/null - echo \${COMPREPLY[@]} + bind -f /etc/inputrc 2>/dev/null + source /etc/bash_completion + for i in /etc/bash_completion.d/*; do source \$i; done + source /usr/share/bash-completion/bash_completion + [[ -f /usr/share/bash-completion/completions/$command ]] && source /usr/share/bash-completion/completions/$command + COMP_WORDS=(${COMP_WORDS[@]}) + COMP_CWORD=$COMP_CWORD + COMP_LINE="$COMP_LINE" + COMP_POINT=$COMP_POINT + COMP_TYPE=9 + COMP_KEY=9 + export COMP_WORDS COMP_CWORD COMP_LINE COMP_POINT COMP_TYPE COMP_KEY + $completion_command 2>/dev/null + echo \${COMPREPLY[@]} EOF )) if [[ $completion_command == '_comp_complete_longopt' ]]; then @@ -115,12 +120,14 @@ EOF fi else + echo -e "\nNO completion_command JUST plain files and firs" >&2 compopt -o filenames compopt -o nospace COMPREPLY=($( incus exec "$container" -- bash << EOF - source /etc/bash_completion - compgen -f "$cur" 2>/dev/null + bind -f /etc/inputrc 2>/dev/null + source /etc/bash_completion + compgen -f "$cur" 2>/dev/null EOF )) fi diff --git a/tools/miaou-exec b/tools/miaou-exec index 8dce323..4fa11a4 100755 --- a/tools/miaou-exec +++ b/tools/miaou-exec @@ -9,8 +9,13 @@ COMMAND='' # FUNCTIONS function usage { - echo "$(basename "$0") -- " - echo -e "$(basename "$0") -- bash < [--] " + echo + echo "Examples:" + echo -e "\t$(basename "$0") container1 uptime" + echo -e "\t$(basename "$0") container1 -- ls -la" + echo -e "\t$(basename "$0") container1 -- bash <