How to save user made zsh shell functions and aliases

4

Shell beginner here! I'd like to create aliases and functions in zsh shell to speed up my workflow. For example:

tw() { open -a //Applications/Textwrangler.app "$*"; }

The function itself works, but the problem is that the function definition disappears once I exit the shell. What's the procedure for saving user defined functions and aliases for future use? The zsh documentation isn't particularly helpful... or maybe I'm just being stupid!

Juho Karppinen

Posted 2015-04-21T07:04:45.060

Reputation: 53

Answers

5

What's the procedure for saving user defined functions and aliases for future use?

You probably want to save your customisations in ~/.zshrc.

~/.zshrc is always executed when zsh starts (both interactive logins and non-interactive logins).


Further reading

  • zsh - Installation and Configation, links to example configuration files.

DavidPostill

Posted 2015-04-21T07:04:45.060

Reputation: 118 938

Thanks! Since I have oh-my-zsh installed, a comment inside of ~/.zshrc suggested I add my customizations to the ~/.oh-my-zsh/custom folder, using any filename with a .zsh extension. – Juho Karppinen – 2015-04-21T09:18:38.400