Browse Source

optional compopt according to commands or files

main
pvincent 3 weeks ago
parent
commit
0163c57bc1
  1. 3
      .vscode/settings.json
  2. 16
      lib/miaou.completion

3
.vscode/settings.json

@ -23,7 +23,8 @@
"**/*.txt",
"**/*.mdown",
"**/*.md",
"**/*.container",
"**/*.recipe",
"**/*.completion",
"**/miaou-*",
],
"todohighlight.enableDiagnostics": true,

16
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
))
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

Loading…
Cancel
Save