Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: multi-alias syntax



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:

> This should work
>
>     alias {a,b,c}=d
>
> unless you have the ignore_braces option set.

That works, thank you.

I also learned I can do

    debian-version debian-ver version ver () { lsb_release -a } # 1

or, as I first thought and as you helped:

    # 2
    debian-version () { lsb_release -a }
    alias {debian-ver,version,ver}=debian-version

Anyone cares to line up the pros and cons of the two
approaches? - in terms of programming, and use.

I can already tell they are not identical as in (1)
debian-ver etc. are functions, not aliases.

I happen to use a function I wrote called 't' (for
"type") [1] in which the function approach is better
(due to the functionality of t, of course) as

    $ t ver
    ver: aliased to debian-version

(doesn't say a lot) vs.

    $ t ver
    ver () {
            lsb_release -a
    }

Some programmers feel all things should have one name
each and you should just memorize it. I sort of
disagree. I want long and descriptive name in the
source so I can understand it years later. But for
interactive use I want short names in many versions.
Every time I make a mistake ("zsh: command not found")
I stop to think "OK, it isn't there. But does it make
sense still?" - if it does, I add an alias.
This method will make that easier and perhaps I'll
drop the alias method completely and have multiple
function names instead, so it will be interesting to
hear if there is any fine print to either methods.

Another thing I can tell you about the multiple
function names method is that it breaks Emacs' zsh
mode as you see in this dump [2].

[1] http://user.it.uu.se/~embe8573/conf/.zsh/ide (line 45)
[2] http://user.it.uu.se/~embe8573/dumps/zsh-font-lock.png

-- 
underground experts united
http://user.it.uu.se/~embe8573



Messages sorted by: Reverse Date, Date, Thread, Author