PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > bash completion (fixed directory)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

bash completion (fixed directory)

Réponse
 
LinkBack Outils de la discussion
Vieux 07/11/2006, 09h47   #1
Yakov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut bash completion (fixed directory)

(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

  Réponse avec citation
Vieux 07/11/2006, 18h31   #2
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash completion (fixed directory)

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
  Réponse avec citation
Vieux 07/11/2006, 21h27   #3
Yakov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash completion (fixed directory)

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

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h53.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09241 seconds with 11 queries