[Bash-completion-devel] Get stuck

Ville Skyttä ville.skytta at iki.fi
Mon May 23 20:39:45 UTC 2011


On 05/23/2011 02:45 AM, Igor Murzov wrote:
> Hey! I get stuck trying to implement completion script for strings containing 
> two parts for completion delimited by '%' sign.  For example, `cmd opt%arg`. 
> The problem is that, if i hit tab key, when cursor is behind delimeter, bash 
> eats first part of string leaving `cmd arg`.
[...]
>     if [[ "$cur" == ?*%* ]]; then
>         cur="${cur#*%}"
>         COMPREPLY=( $( compgen -W 'abc bbb cde' -- "$cur" ) )
>         return 0
>     fi

Not sure if I understand correctly, but does replacing the above with
this work the way you'd like?

    if [[ "$cur" == ?*%* ]]; then
        COMPREPLY=( $( compgen -P "${cur%%%*}%" \
            -W 'abc bbb cde' -- "${cur#*%}" ) )
        return 0
    fi



More information about the Bash-completion-devel mailing list