You are not logged in.
Hey guys!
In my .bash_aliases file I had something like this:
cd_func()
{
cd $1 && ls
}
alias cd='cd_func'
It showed me the directories from the directory that I moved into. When adding this to a .zshrc (or .zsh_aliases) it complains about ...
maximum nested function level reached
... because it creates an infinite loop. How can I achieve my desired behaviour? I am using grml-zsh-config and saw there's a "cl" function which does exactly the same as I want (cd && ls) but I still have to type cl instead of cd everytime I want to change directory.
So I tried ...
alias cd='cl'
... but there's the infinite loop again.
Please, someone help me.
Last edited by akurei (2010-11-23 21:28:07)
Offline
Either use the `builtin` keyword inside your function to prevent the function from being recursively called, or (even better) use the zsh provided chpwd() hook to run ls instead.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
or just name your function "cd" and avoid the alias
Offline
Either use the `builtin` keyword
Yes! That did the trick!
in ~/.zsh_aliases:
cd()
{
builtin cd $1 && ls
}
inside your function to prevent the function from being recursively called, or (even better) use the zsh provided chpwd() hook to run ls instead.
chpwd() hook? Could you please give an example for me?
or just name your function "cd" and avoid the alias
That did not work, unfortunately.
Thanks, both of you!
Last edited by akurei (2010-11-23 21:26:41)
Offline
chpwd() hook? Could you please give an example for me?
See my zshrc in my dotfiles repo below.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline