15

I'm preparing a bash script, that will set a bunch of handy shell aliases at once. I'm using a pair of iTerm2 and oh-my-zsh.

I know that I can manually add aliases into ~/.zshrc. I also know that I can even to that automatically by calling sed with some extra stuff, but for separation and consistency I would like to keep my "omz" aliases in a separate file like ~/.bash_aliases?

So then my bash script could easily override the content of that file and put a list of my aliases without worrying, that I will remove by accident some other settings from ~/.zshrc.

How I could specify a separate file for aliases in oh-my-zsh?

Matt Komarnicki
  • 287
  • 1
  • 2
  • 11
  • Where you are inserting your aliases in `~/.zshrc`, replace them with `. ~/.zsh_aliases`, where you put the aliases instead. – AFH Oct 31 '16 at 01:23

2 Answers2

19

All you need to do is to remove the alias definitions from ~/.zshrc into the file ~/.zsh_aliases and replace the multiple alias commands in ~/.zshrc by:

. ~/.zsh_aliases

You can use the same technique for other sections of ~/.zshrc: for instance, you may find it convenient to move any function definitions into ~/.zsh_functions.

AFH
  • 17,300
  • 3
  • 32
  • 48
3

In my case, i'm using oh-my-zsh and in the ~/.zshrc file i placed the linked file path as

source FILE_PATH

then restart the terminal and all done.

sh6210
  • 131
  • 4