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?

1
  • Where you are inserting your aliases in ~/.zshrc, replace them with . ~/.zsh_aliases, where you put the aliases instead.
    – AFH
    Oct 31, 2016 at 1:23

2 Answers 2

20

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.

0
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .