On 11/7/24 9:53 AM, Clark Wang wrote:
See the following reproduce example:$ cat ssh_compspec COMP_WORDBREAKS=${COMP_WORDBREAKS//[=:]/} function _ssh() { local cur="$2" pre="$3" local options=( ProxyCommand='/usr/bin/nc -x host:port %h %p -X 5' ProxyCommand='/usr/bin/nc -x host:port %h %p -X connect' ConnectTimeout=10 ) local i saveIFS="$IFS" if [[ $pre == '-o' ]]; then for ((i=0; i < ${#options[@]}; ++i)); do options[i]=$( printf '%q' "${options[i]}" ) done IFS=$'\n' COMPREPLY=( $( compgen -W "${options[*]}" -- "$cur" ) ) IFS=$saveIFS fi } complete -F _ssh -o filenames ssh $ . ./ssh_compspec Then, $ ssh -o <Tab><Tab> ConnectTimeout=10 nc -x host:port %h %p -X 5 nc -x host:port %h %p -X connect As we can see, "ProxyCommand" is missing.
OK. You asked for the completions to be treated as filenames. When readline displays the possible completions for filenames, it doesn't display the full pathname -- just the portion after the final slash. The words with ProxyCommand= are trimmed to the portion after the .../usr/bin/. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature