I want to record the latest cd through any of my terminals. I thought a good way to do this is to write a simple bash script wrapping cd :
#!/bin/bash cd $1 && echo `pwd` > /tmp/.cwd
Since I want cd execute in my terminal process, I need to run the script with . bettercd.sh . bettercd.sh , right?
Here is my problem: If I add cd to this new one . bettercd.sh . bettercd.sh , my shell also extends cd inside the script with . bettercd.sh . bettercd.sh - infinite recursion.
Is there a way to call cd from a different name but with the same behavior? In other words, is there some kind of command that behaves exactly (or very similar to) cd that I can use in my shell script without noticing the difference when I use the alias cd day after day?
My shell of choice is zsh, if that matters in some way.
Thanks for your help.
source share