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", "**/*.txt",
"**/*.mdown", "**/*.mdown",
"**/*.md", "**/*.md",
"**/*.container",
"**/*.recipe",
"**/*.completion",
"**/miaou-*", "**/miaou-*",
], ],
"todohighlight.enableDiagnostics": true, "todohighlight.enableDiagnostics": true,

16
lib/miaou.completion

@ -62,16 +62,30 @@ function _miaou_exec() {
if ((COMP_CWORD == 3)); then if ((COMP_CWORD == 3)); then
# command or file from inside container # command or file from inside container
# echo -e "\nCOMMAND or FILE from CONTAINER\n" >&2 # echo -e "\nCOMMAND or FILE from CONTAINER\n" >&2
COMPREPLY=($(
COMPREPLY_COMMANDS=($(
incus exec "$container" -- bash << EOF incus exec "$container" -- bash << EOF
bind -f /etc/inputrc 2>/dev/null bind -f /etc/inputrc 2>/dev/null
source /etc/bash_completion source /etc/bash_completion
compgen -c -- "$cur" 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" compgen -f -- "$cur"
EOF EOF
)) ))
COMPREPLY=(${COMPREPLY_COMMANDS[@]} ${COMPREPLY_FILES[@]})
if [[ ${#COMPREPLY_FILES[@]} -gt 0 ]]; then
compopt -o filenames compopt -o filenames
compopt -o nospace compopt -o nospace
fi
# echo -e "\nCOMPREPLY=( ${COMPREPLY[@]} ) FILES=${#COMPREPLY_FILES[@]}\n" >&2
return return
fi fi

Loading…
Cancel
Save