Dynamic aliases in zsh
I work with project which consists of many subdirectories. When I wanted go to specific directory, I went to the root of project and then changed to specific directory. I decided to optimize this a little bit.
My first approach looked like that:
alias p='cd /path/to/project' alias subdirectory1='cd /path/to/project/subdirectory1' alias subdirectory2='cd /path/to/project/subdirectory2' ... ...
It came to my mind that I can define dynamically all necessary aliases. I added to my
.zshrc following lines:
for folder in `ls /path/to/project`; do alias $folder="cd /path/to/project/$folder"; done;
Of course this solution add small overhead when loading
.zshrc but it is much simpler and easier to maintain.