So I've got ZSH doing all this cool stuff now, but what would be REALLY awesome is if I could get it to run 'ls -a' implicitly after every time I call 'cd'. I figure this must go in the .zlogin file or the .aliases file, I'm just not sure what the best solution is. Thoughts? Reference material?
+1
A:
Write a function that performs the cd
as requested, then performs a ls -a
. Make sure you don't make it terribly difficult to disable though.
Ignacio Vazquez-Abrams
2010-10-18 22:52:57
+1
A:
You can do this via a simple alias:
alias cd='cd $* && ls -a'
Put this in your .zshrc
Brian Agnew
2010-10-18 22:59:47
Downvoted why ?
Brian Agnew
2010-10-18 23:04:37
Not a clue. Maybe someone thinks that you can't use positional parameters in aliases in zsh.
Ignacio Vazquez-Abrams
2010-10-18 23:07:35
-1: alias is not a function, so `ls -a` will get the arguments while `cd` will not. You should have used function.
ZyX
2010-10-18 23:10:57
@Ignacio Vazquez-Abrams you think you can?
ZyX
2010-10-18 23:12:40
My tests (against zsh 4.3.9) suggest otherwise and that this works fine and as requested by the original questioner.
Brian Agnew
2010-10-18 23:14:06
I can't duplicate your success with 4.3.10 here.
Ignacio Vazquez-Abrams
2010-10-18 23:20:45
@Brian Agnew zsh 4.3.10, running this command before cd results in changing directory to `$HOME` and running a `ls -a` with all other arguments. Can you point where such `alias+$*` behavior is mentioned in documentation?
ZyX
2010-10-18 23:22:19
I don't. I'm simply working from what's working on my current install.
Brian Agnew
2010-10-18 23:26:19
I cannot find anything directly related to that in changelog, they only added `posixaliases` option setting/unsetting which does not alter the behavior of this alias.
ZyX
2010-10-18 23:35:46
This works really well, I forgot to mention I have auto_cd turned on so this only works when I explicitly call 'cd'. Is there a way to get this to behave this way any time I change directories?
drmanitoba
2010-10-19 14:56:13