diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
commit | f2621414ee5f2f601424c22f00e207903e3b6104 (patch) | |
tree | 56a856dafd1ca684bb23263cacaa723ee4f404fc /completions/screen | |
parent | Adding debian version 1:2.11-8. (diff) | |
download | bash-completion-f2621414ee5f2f601424c22f00e207903e3b6104.tar.xz bash-completion-f2621414ee5f2f601424c22f00e207903e3b6104.zip |
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/screen')
-rw-r--r-- | completions/screen | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/completions/screen b/completions/screen index 651ca2c..ab4b7dd 100644 --- a/completions/screen +++ b/completions/screen @@ -1,12 +1,13 @@ # bash completion for screen -*- shell-script -*- -_screen_sessions() +_comp_cmd_screen__sessions() { - local sessions=($(command screen -ls | command sed -ne \ - 's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p')) + local -a sessions + _comp_split sessions "$(command screen -ls | command sed -ne \ + 's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p')" || return if [[ $cur == +([0-9])?(.*) ]]; then # Complete sessions including pid prefixes - COMPREPLY=($(compgen -W '${sessions[@]}' -- "$cur")) + _comp_compgen -- -W '"${sessions[@]}"' else # Create unique completions, dropping pids where possible local -A res @@ -17,26 +18,22 @@ _screen_sessions() for i in "${!res[@]}"; do [[ ${res[i]} == \ *\ * ]] && tmp+=" ${res[i]}" || tmp+=" $i" done - COMPREPLY=($(compgen -W '$tmp' -- "$cur")) + _comp_compgen -- -W '$tmp' fi } && - _screen() + _comp_cmd_screen() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return if ((cword == 1)); then if [[ $cur == /dev* ]]; then - COMPREPLY=($(compgen -W "$( - shopt -s nullglob - printf '%s\n' \ - /dev/serial/by-id/* /dev/ttyUSB* /dev/ttyACM* 2>/dev/null - )" \ - -- "$cur")) + _comp_expand_glob COMPREPLY '/dev/serial/*/* /dev/ttyUSB* /dev/ttyACM*' && + _comp_compgen -- -W '"${COMPREPLY[@]}"' return fi if [[ $cur == //* ]]; then - COMPREPLY=($(compgen -W '//telnet' -- "$cur")) + _comp_compgen -- -W '//telnet' return fi fi @@ -44,14 +41,14 @@ _screen_sessions() case ${words[1]} in /dev*) if ((cword == 2)); then - COMPREPLY=($(compgen -W '110 300 600 1200 2400 4800 9600 \ - 14400 19200 38400 57600 115200 128000 256000' -- "$cur")) + _comp_compgen -- -W '110 300 600 1200 2400 4800 9600 14400 + 19200 38400 57600 115200 128000 256000' # TODO more, comma separated options fi return ;; //telnet) - ((cword == 2)) && _known_hosts_real -- "$cur" + ((cword == 2)) && _comp_compgen_known_hosts -- "$cur" return ;; esac @@ -59,7 +56,7 @@ _screen_sessions() if ((cword > 2)); then case ${words[cword - 2]} in -*[dD]) - _screen_sessions + _comp_cmd_screen__sessions return ;; esac @@ -77,36 +74,36 @@ _screen_sessions() ;; esac - _command_offset $i + _comp_command_offset $i return done case $prev in -*[rR]) # list detached - _screen_sessions 'Detached' + _comp_cmd_screen__sessions 'Detached' return ;; -*[dD]) # list attached - _screen_sessions 'Attached' + _comp_cmd_screen__sessions 'Attached' return ;; -*x) # list both - _screen_sessions + _comp_cmd_screen__sessions return ;; -*s) - _shells + _comp_compgen_shells return ;; -*c) - _filedir + _comp_compgen_filedir return ;; -T) - _terms + _comp_compgen_terms return ;; -*[ehpSt]) @@ -115,9 +112,9 @@ _screen_sessions() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help fi } && - complete -F _screen screen + complete -F _comp_cmd_screen screen # ex: filetype=sh |