[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Command completion with * in the middle?
From: |
Peng Yu |
Subject: |
Re: [Help-bash] Command completion with * in the middle? |
Date: |
Mon, 28 Jan 2019 13:12:01 -0600 |
> > f() {
> > local globchars='*?['
> > shopt -q extglob && globchars+='address@hidden'
> > local head=${3%%["$globchars"]*}
> > COMPREPLY=($(compgen -c -X '!'"$3" -- "$head"))
> > }
>
> Indeed. This is much faster. Thanks.
This is buggy. I type bash<TAB>, I will miss commands starting with bash.
So I fix it with a test.
function __pattern_complete {
local globchars='*?['
shopt -q extglob && globchars+='address@hidden'
local head=${3%%["$globchars"]*}
if [[ $3 == $head ]]; then
COMPREPLY=($(compgen -c -- "$head"))
else
COMPREPLY=($(compgen -c -X '!'"$3" -- "$head"))
fi
}
complete -I -F __pattern_complete -o bashdefault
--
Regards,
Peng
- Re: [Help-bash] Command completion with * in the middle?, (continued)
- Re: [Help-bash] Command completion with * in the middle?, Chet Ramey, 2019/01/20
- Re: [Help-bash] Command completion with * in the middle?, Peng Yu, 2019/01/22
- Re: [Help-bash] Command completion with * in the middle?, Chet Ramey, 2019/01/22
- Re: [Help-bash] Command completion with * in the middle?, Peng Yu, 2019/01/22
- Re: [Help-bash] Command completion with * in the middle?, Chet Ramey, 2019/01/22
- Re: [Help-bash] Command completion with * in the middle?, Peng Yu, 2019/01/22
- Re: [Help-bash] Command completion with * in the middle?, Chet Ramey, 2019/01/22
- Re: [Help-bash] Command completion with * in the middle?, Peng Yu, 2019/01/22
- Re: [Help-bash] Command completion with * in the middle?, Koichi Murase, 2019/01/26
- Re: [Help-bash] Command completion with * in the middle?, Peng Yu, 2019/01/26
- Re: [Help-bash] Command completion with * in the middle?,
Peng Yu <=
- Re: [Help-bash] Command completion with * in the middle?, doark, 2019/01/26
- Re: [Help-bash] Command completion with * in the middle?, Koichi Murase, 2019/01/26
Re: [Help-bash] Command completion with * in the middle?, Peng Yu, 2019/01/22
Re: [Help-bash] Command completion with * in the middle?, Greg Wooledge, 2019/01/21