From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1142 invoked from network); 7 Sep 2006 19:21:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-25) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 7 Sep 2006 19:21:30 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 7894 invoked from network); 7 Sep 2006 19:21:24 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 7 Sep 2006 19:21:24 -0000 Received: (qmail 27418 invoked by alias); 7 Sep 2006 19:21:16 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10692 Received: (qmail 27407 invoked from network); 7 Sep 2006 19:21:15 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 7 Sep 2006 19:21:15 -0000 Received: (qmail 6674 invoked from network); 7 Sep 2006 19:21:15 -0000 Received: from ms-1.rz.rwth-aachen.de (HELO ms-dienst.rz.rwth-aachen.de) (134.130.3.130) by a.mx.sunsite.dk with SMTP; 7 Sep 2006 19:21:13 -0000 Received: from r220-1 (r220-1.rz.RWTH-Aachen.DE [134.130.3.31]) by ms-dienst.rz.rwth-aachen.de (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTP id <0J5800627LRCC8@ms-dienst.rz.rwth-aachen.de> for zsh-users@sunsite.dk; Thu, 07 Sep 2006 21:21:13 +0200 (MEST) Received: from relay.rwth-aachen.de ([134.130.3.1]) by r220-1 (MailMonitor for SMTP v1.2.2 ) ; Thu, 07 Sep 2006 21:21:12 +0200 (MEST) Received: from fsst.voodoo.lan (i577BC58F.versanet.de [87.123.197.143]) by relay.rwth-aachen.de (8.13.7/8.13.3/1) with ESMTP id k87JLC0l027930 for ; Thu, 07 Sep 2006 21:21:12 +0200 (MEST) Received: from hawk by fsst.voodoo.lan with local (Exim 4.63) (envelope-from ) id 1GLPQ5-0001xk-M1 for zsh-users@sunsite.dk; Thu, 07 Sep 2006 21:20:13 +0200 Date: Thu, 07 Sep 2006 21:20:13 +0200 From: Frank Terbeck Subject: Re: global aliases and scripts in $path In-reply-to: <8fa44mahj1nj$.1fkuabkux8c7f.dlg@40tude.net> To: zsh-users@sunsite.dk Mail-followup-to: zsh-users@sunsite.dk Message-id: <20060907192013.GD30636@fsst.voodoo.lan> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline Operating-System: Linux 2.6.16.16 i686 User-Agent: Mutt/1.5.13 (2006-08-11) References: <8fa44mahj1nj$.1fkuabkux8c7f.dlg@40tude.net> Thorsten Kampe : > I've got a few global aliases[1] that allow me run my preferred > scripts without the "./" nuisance (no I generally don't want the > current folder in my path because of the security implications). > > [1] alias -s exe=wine \ > py=python \ > zsh=zsh These are not global, but suffix aliases. For a disambiguation of the two, see: > This works fine but a few apps in /bin have an extension. So when I > type rst2html.py (which is in /bin) python says it can't find the file > (yep, it's not in the current directory). > > Is there a way out of this dilemma - meaning keeping the useful global > alias and also be able to run files in $path who have an aliases > extension?! If you do this because of your "preferred scripts", as you said, create a new directory ~/bin and put your scripts in there, and add that directory to your path: path=( ~/bin $path ); That way you can call your scripts like normal programs (which is preferable, IMHO). If you want those suffix aliases by all means, the only solution I can think of is this: [snip] zsh% print =pv.sh /usr/bin/pv.sh zsh% pv.sh usage: /usr/bin/pv.sh page_number file_name[.dvi] zsh% alias -s sh=/bin/sh zsh% pv.sh /bin/sh: Can't open pv.sh zsh% alias pv.sh=/usr/bin/pv.sh zsh% pv.sh usage: /usr/bin/pv.sh page_number file_name[.dvi] [snap] You would have to create aliases for all commands in your $path that end in the extensions you got suffix-aliases. That could be done in a loop: [snip] extensions=( exe py zsh ) for binary in ${^path}/**/*.${^extensions}(N) ; do command=${binary:t} alias $command=$binary done [snap] Though, I would prefer the ~/bin solution. Regards, Frank