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

RE: strange alias effects



> In my dot-files I've got this (among others):
>  alias psl='ps -eo
> user,pid,ppid,cpu,pmem,rss,vsize,bsdtime,bsdstart,cmd --sort
> user,pid | \grep -v "bsdtime,bsdstart"'
>  alias pslS='ps -eo
> user,pid,ppid,cpu,pmem,rss,vsize,bsdtime,bsdstart,cmd --sort
> -size | \grep -v "bsdtime,bsdstart"'
>  look.for () { psl | \grep -iE "(^USER|$@)" | \grep -v "grep -iE" }
>  alias lookall='psl | grep -vE "(^($USERNAME|root|bin))|login"'
>
> When I type
>  look.for ssh-agent
> I get:
>  look.for: command not found: psl
>
> "lookall" works as usual.
>

This trick works for me:

bor@itsrm2% cat ~/.zsh.d/functions/bar
foo
bor@itsrm2% alias foo='echo xxx'
bor@itsrm2% autoload bar
bor@itsrm2% bar
xxx

Note, that this works irrespectively of alias/autoload order.

I actually think, that autoloading functions provides more clean way
than definig them directly in dot-files.


> After typing
>  look.for () { psl | \grep -iE "(^USER|$@)" | \grep -v "grep -iE" }
> on the shell prompt, it works.
>
> Can anyone explain this to me, please?

Well, aliases are not expanded in direct function defiition (correct me,
Bart). Weirdly enough, they are expanded (by default) in autoloaded
functions.

-andrej



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