summaryrefslogtreecommitdiffstats
path: root/completions/xfreerdp
diff options
context:
space:
mode:
Diffstat (limited to 'completions/xfreerdp')
-rw-r--r--completions/xfreerdp63
1 files changed, 37 insertions, 26 deletions
diff --git a/completions/xfreerdp b/completions/xfreerdp
index f17414f..66b42ad 100644
--- a/completions/xfreerdp
+++ b/completions/xfreerdp
@@ -1,67 +1,78 @@
# xfreerdp completion -*- shell-script -*-
-_xfreerdp()
+_comp_cmd_xfreerdp()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
- case $prev in # old/dash syntax
+ case $prev in
-k)
- COMPREPLY=($(compgen -W '$("$1" --kbd-list |
- awk "/^0x/ { print \$1 }")' -- "$cur"))
+ _comp_compgen_split -- "$("$1" --kbd-list |
+ _comp_awk '/^0x/ { print $1 }')"
return
;;
-a)
- COMPREPLY=($(compgen -W '8 15 16 24 32' -- "$cur"))
+ _comp_compgen -- -W '8 15 16 24 32'
return
;;
-x)
- COMPREPLY=($(compgen -W 'broadband modem lan' -- "$cur"))
+ _comp_compgen -- -W 'broadband modem lan'
return
;;
--plugin)
- COMPREPLY=($(compgen -W 'cliprdr rdpsnd rdpdr' -- "$cur"))
+ _comp_compgen -- -W 'cliprdr rdpsnd rdpdr'
+ return
+ ;;
+ /help | /version | -h | --help | --version)
return
;;
esac
- case $cur in # new/slash syntax
+ case $cur in
/kbd:*)
- COMPREPLY=($(compgen -W '$("$1" /kbd-list |
- awk "/^0x/ { print \$1 }")' -- "${cur#/kbd:}"))
+ local kbd_list
+ kbd_list=$("$1" /kbd-list 2>/dev/null) ||
+ kbd_list=$("$1" /list:kbd 2>/dev/null)
+ _comp_compgen -c "${cur#/kbd:}" split -- "$(
+ _comp_awk '/^0x/ { print $1 }' <<<"$kbd_list"
+ )"
return
;;
/bpp:*)
- COMPREPLY=($(compgen -W '8 15 16 24 32' -- "${cur#/bpp:}"))
+ _comp_compgen -c "${cur#/bpp:}" -- -W '8 15 16 24 32'
return
;;
- /*:* | /help | /version | -h | --help | --version)
+ /*:*)
return
;;
esac
if [[ $cur == /* ]]; then
- COMPREPLY=($(compgen -W '$("$1" --help |
- awk "\$1 ~ /^\\// && \$1 !~ /^.(flag\$|option:)/ { sub(\":.*\",\":\",\$1); print \$1 }")' \
- -- "$cur"))
+ _comp_compgen_filedir rdp
+ _comp_compgen -a split -- "$(
+ "$1" --help | _comp_awk '$1 ~ /^\// && $1 !~ /^.(flag$|option:)/ {
+ sub(":.*",":",$1); print $1 }'
+ )"
[[ ${COMPREPLY-} == *: ]] && compopt -o nospace
elif [[ $cur == [+-]* ]]; then
local char=${cur:0:1}
- local help="$($1 --help)"
+ local help="$("$1" --help)"
if [[ $help == */help* ]]; then # new/slash syntax
- COMPREPLY=($(compgen -W '$(awk "
- \$1 ~ /^[+-]/ && \$1 !~ /^.toggle\$/ { sub(\"^.\",\"$char\",\$1); print \$1 }
- " <<<"$help")' -- "$cur"))
+ _comp_compgen_split -- "$(_comp_awk '$1 ~ /^[+-]/ && $1 !~ /^.toggle$/ {
+ sub("^.","'"$char"'",$1); print $1 }' <<<"$help")"
else # old/dash syntax
- COMPREPLY=($(_parse_help - <<<"$help"))
- COMPREPLY=($(compgen -W '${COMPREPLY[@]%:}' -- "$cur"))
+ _comp_compgen -R help - <<<"$help"
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -W '"${COMPREPLY[@]%:}"'
fi
else
- COMPREPLY=($(compgen -W "$(awk '{print $1}' ~/.freerdp/known_hosts \
- 2>/dev/null)" -- "$cur"))
+ _comp_compgen_filedir rdp
+ _comp_compgen -a split -- "$(
+ _comp_awk '{print $1}' ~/.freerdp/known_hosts 2>/dev/null
+ )"
fi
} &&
- complete -F _xfreerdp xfreerdp
+ complete -F _comp_cmd_xfreerdp xfreerdp
# ex: filetype=sh