[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question. Autocomplete paths starting with %.
From: |
Clark J. Wang |
Subject: |
Re: Question. Autocomplete paths starting with %. |
Date: |
Wed, 23 Feb 2011 12:06:12 +0800 |
On Sat, Feb 19, 2011 at 9:20 PM, dpc@ucore.info <dpc@ucore.info> wrote:
>
> I can script in Bash quite well, but I've never did anything that
> fancy with completion and I don't know how to plug my function to
> handle this. I understand that I should register something (function
> named like _bookmarkcomp) to handle filename completion for things
> beginning with %.
>
> If you help me with this one I promise to post my solution for benefit
> of other bash users.
>
> Regards,
> Dawid
> --
> http://dpc.ucore.info
>
>
I can give you an example here:
bash# vi compgen-example.sh
_compgen_foo()
{
local cmd=$1 cur=$2 pre=$3
if [[ $cur = % ]]; then
COMPREPLY[0]='it-works'
fi
}
complete -F _compgen_foo foo
bash# source compgen-example.sh
bash# foo %<TAB> <-- Press TAB here
bash# foo it-works <-- `%' will be expanded like this
--
Clark J. Wang