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

Re: real time alias?



I know this is from a couple of days ago, but:

On Thu, Mar 15, 2018 at 2:44 PM, Marc Chantreux <eiro@xxxxxxxxx> wrote:
>
>     rip () {
>         print $1 wrote
>         "$@"
>         print then $1 died
>     }
>     alias stephen='print a brief history of time'
>     rip stephen hawkings

This isn't a very good example because "rip" would not use the alias
even if "stephen" had been explicitly mentioned in the function body.
You'd have to define them in the opposite order.

Also this:

> warn_ () { local r=$?; print -u2 "$*"; return $r }
> alias warn='warn_ at $0 line $LINENO, warning:'

Can be done directly like this:

alias warn='() { local r=$?; print -u2 "$*"; return $r } "at $0 line
$LINENO, warning: "'

in any zsh from the past several years that supports anonymous function scopes.



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