|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
(posted earlier to gnu.bash, but no relpies yet)
I want to define bash completion for command xyz as follows: [when I press tab], argument for command xyz is completed from filenames in [fixed] directory /home/xyz, (not from current directory), and preferrabley without the /home/xyz prefix. How do I do it ? Thanks Yakov |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 2006-11-07, Yakov wrote:
> (posted earlier to gnu.bash, but no relpies yet) > > I want to define bash completion for command xyz as > follows: [when I press tab], argument for command xyz > is completed from filenames in [fixed] directory /home/xyz, > (not from current directory), and preferrabley without > the /home/xyz prefix. How do I do it ? _xyz() { COMPREPLY=( ` cd /home/xyz || return 3 printf "%s\n" ${COMP_WORDS[$COMP_CWORD]}*` ) COMPREPLY=( "${COMPREPLY[@]%-sh}" ) } complete -F _xyz xyz -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Chris F.A. Johnson wrote:
> On 2006-11-07, Yakov wrote: > > (posted earlier to gnu.bash, but no relpies yet) > > > > I want to define bash completion for command xyz as > > follows: [when I press tab], argument for command xyz > > is completed from filenames in [fixed] directory /home/xyz, > > (not from current directory), and preferrabley without > > the /home/xyz prefix. How do I do it ? > > _xyz() { > COMPREPLY=( ` > cd /home/xyz || return 3 > printf "%s\n" ${COMP_WORDS[$COMP_CWORD]}*` > ) > COMPREPLY=( "${COMPREPLY[@]%-sh}" ) > } > complete -F _xyz xyz Thanks, this works great. Yakov |
|
![]() |
| Outils de la discussion | |
|
|