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

Re: Best practices for managing aliases in ohmyzsh?



On Tue, Aug 31, 2021 at 11:23 PM Steve Dondley <s@xxxxxxxxxxx> wrote:
>
> And so long as I only call these scripts
> with an alias, there shouldn't be any performance penalty because they
> won't all have to be sourced by zsh.

Forgot to mention that there is no performance difference between
invoking a script directly or via an alias. When you use an alias, it
first gets expanded, and then the expansion is executed as if you
typed it. For example:

  % alias foo=cat
  % foo

When you hit ENTER after foo, zsh will realize that foo is an alias
and will replace it with cat. After that it'll execute cat the same
way as if you typed it yourself. Aliases are like (unhygienic) macros.

When you execute an executable file -- be it a script or a binary file
-- zsh never sources it. It uses execve(2) or something similar to
execute the file. To source a file you need to explicitly run `source
foo` or `. foo`.

Roman.




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