[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Completion based on both prefix and suffix
From: |
Davide Brini |
Subject: |
Re: [Help-bash] Completion based on both prefix and suffix |
Date: |
Sat, 27 Apr 2013 17:22:46 +0200 |
On Sat, 27 Apr 2013 10:08:09 -0500, Peng Yu <address@hidden> wrote:
> Hi,
>
> I sourced the following bash script.
> ~$ cat main.sh
> #!/usr/bin/env bash
>
> function _mycomp {
> echo
> echo '_mycomp:BEGIN'
> printf '_mycomp:$@ = %s\n' "$@"
> echo '_mycomp:END'
> }
>
> function mycomp {
> :
> }
>
> complete -F _mycomp mycomp
> ~$ . main.sh
>
> When I type <TAB> after 'ma' in 'ma.sh', I'd like to get only ma but
> also what is after it, i.e. '.sh', so that I can complete the complete
> the command not only based on prefix but also on suffix. Is it feature
> available in bash?
>
> ~$ mycomp a ma.sh
> _mycomp:BEGIN
> _mycomp:$@ = mycomp
> _mycomp:$@ = ma
> _mycomp:$@ = a
> _mycomp:END
> ^C
COMP_WORDS gives the full command line. The man has the details.
--
D.