zsh-users
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.de>
To: zsh-users@sunsite.dk
Subject: Re: global aliases and scripts in $path
Date: Thu, 07 Sep 2006 21:20:13 +0200	[thread overview]
Message-ID: <20060907192013.GD30636@fsst.voodoo.lan> (raw)
In-Reply-To: <8fa44mahj1nj$.1fkuabkux8c7f.dlg@40tude.net>

Thorsten Kampe <thorsten@thorstenkampe.de>:
> 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:
<http://zshwiki.org/home/examples/aliasglobal>
<http://zshwiki.org/home/examples/aliassuffix>

> 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


      reply	other threads:[~2006-09-07 19:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-07 18:41 Thorsten Kampe
2006-09-07 19:20 ` Frank Terbeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060907192013.GD30636@fsst.voodoo.lan \
    --to=ft@bewatermyfriend.de \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).