Symfony based autocomplete breaks SCP autocomplete
This has probably nothing to do with your robo
compspec. Nor with the _scp
completion function associated with scp
.
It is probably due to your COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
.
You removed :
from the list of separators. Apparently _scp
is robust enough to behave the same with or without :
as a word separator. It returns the same list of candidate completions. But the token that gets substituted when _scp
returns only one candidate for the completion of, e.g. scp host:public_ht
, is host:public_ht
, instead of just public_ht
. Proof:
$ _foobar () { COMPREPLY=bazcux; return 0; }$ complete -o default -F _foobar foobar$ echo $COMP_WORDBREAKS"'><=;|&(:
If you try to complete foobar host:public_ht
, you get foobar host:bazcux
because the substituted token is just public_ht
. While with:
$ COMP_WORDBREAKS=${COMP_WORDBREAKS//:}$ echo $COMP_WORDBREAKS"'><=;|&(
if you try to complete foobar host:public_ht
, you get foobar bazcux
because it is the complete host:public_ht
that is replaced by bazcux
.
The solution to your problem is probably to adapt your _robo
completion function such that it does not require that :
is not a word separator. Something like:
_stem () { local lcur lprev lcur="$cur" stem="$lcur" for (( i = cword - 1; i >= 0; i -= 1 )); do lprev="${words[i]}" [[ $lcur == ":" ]] && [[ $lprev == ":" ]] && break [[ $lcur != ":" ]] && [[ $lprev != ":" ]] && break stem="$lprev$stem" lcur="$lprev" done}_robo () { local cur prev words cword _init_completion || return local stem options options=($(__robo_list_opts) $(__robo_list_cmds)) COMPREPLY=() _stem COMPREPLY=($(compgen -W '${options[@]}' -- "$stem")) [[ $stem =~ : ]] && stem=${stem%:*}: && COMPREPLY=(${COMPREPLY[@]#"$stem"}) return 0}complete -o default -F _robo robo
A much (apparently) simpler solution consists in replacing the _stem
function above by the existing __reassemble_comp_words_by_ref
function of the bash_completion
library:
_robo () { local cur prev words cword _init_completion || return __reassemble_comp_words_by_ref ":" words cword options=($(__robo_list_opts) $(__robo_list_cmds)) COMPREPLY=($(compgen -W '${options[@]}' -- "$cur")) return 0}complete -o default -F _robo robo
All this is probably not exactly what you want. I do not know robo.il
and there are probably many improvements that would take more context into account to propose specific completions. But it may be a starting point.