Path to the current script folder in zsh
20 Mar 2023To get the path of the folder of the script currently running in zsh, use ${0:a:h}
. $0
is the path to the currently running script, a
forces it to absolute, and h
to keep the head (the folder).
This is useful when you need to reference scripts that are not in your $PATH
, but are stored close to your initial script.
Want to add something ? Feel free to get in touch on Twitter : @pixelastic