How do I make named directories permanent in zsh and how do I edit them. Also what is the best place to look for documentation.
I just installed zsh and oh-my-zsh and I would like to use the named directories feature, i.e.
% hash -d foo=/etc
% echo ~foo
/etc
However, when I restart my console, these settings are gone. How do I make them permanent?
How do I edit them if, say, I make a typeo when setting the "alias" name.
Where is the best place to look for documentation of zsh?
Is this it? http://zsh.sourceforge.net/Doc/Release/zsh_toc.html
Solution 1:
Set static named directories
Open up ~/.zshrc
in your favorite editor and add the hash commands one after one like you did in your example, e. g.
hash -d foo=/etc
hash -d zshdoc=/usr/share/doc/zsh-common
and so on. The file .zshrc
in your home directory will be loaded every time you start zsh.
Aliases
You can also put your alias definitions there, just the same way. However, it is more useful to put aliases in a separate file, e. g. ~/.zshaliases
and then source this file from .zshrc
. So, add this to .zshrc
:
. ~/.zshaliases
and then add your alias definitions to ~/.zshaliases
like this:
alias ll="ls -l"
alias la="ls -la"
These are just examples of course. The reason to put those aliases in a separate file is, that you can edit it with your favorite editor and then simply reload all aliases by issuing the command . ~/.zshaliases
.
Documentation
Personally I like most the zshall
manual page which you can open by running the command man zshall
. It is very complete.
Other good sources for zsh documentation are:
- http://zsh.sourceforge.net/Doc/Release/zsh_toc.html
- http://www.zzapper.co.uk/zshtips.html
- http://www.zsh.org/cgi-bin/mla/wilma/users (mailing list archive, to look for specific solutions others have asked for already)