I recently switched to MacOS and some aliases in ZSH which were working on a linux system is giving me headaches in MacOS. To be specific, pwd
variable inside alias is using the same directory where it was sourced from. I have to resource .zshrc
from different directories for zsh to recognise pwd
properly.
Here is what I mean. My content in .zshrc
is:
alias myls="ls -lrth $(pwd)"
and here are the results:
~ source ~/.zshrc
~ cd ~
~ alias myls
... myls='ls -lrth /Users/myusername'
~ cd ~/Documents
~ alias myls
... myls='ls -lrth /Users/myusername' <--- It should list content for ~/Document
~ source ~/.zshrc
~ alias myls
... myls='ls -lrth /Users/myusername/Documents' <--- Sourcing again fixes it
Can someone tell me why do I have source my .zshrc
again and again to be able to use $(pwd)
while it works forever in linux in a single source?