The zsh named directory hash table
Like all cool things, it started with a reddit comment. Someone recommended to use the zsh directory hash table. It enabled me to set custom directory replacements like this:
This worked nicely, but I was curious about how it worked.
Since is a zsh built-in function, the docs can be accessed with
hash can be used to directly modify the contents of the command hash table, and the named directory hash table. Normally one would modify these tables by modifying one’s PATH (for the command hash table) or by creating appropriate shell parameters (for the named directory hash table). The choice of hash table to work on is determined by the -d option; without the option the command hash table is used, and with the option the named directory hash table is used.
To display the command hash table contents, run
hash. For the directory hash table, run
So the use of
hash -d github=~/Documents/GitHub only added the value to a cache.
I found out that you can also add a static named directory like this:
The documentation for this behaviour can be found here.
So every variable starting with a slash is considered. Also every users home is included automatically.