Sourcing an alias file in oh my zsh custom/ folder

5

I am trying to use the aliases defined in my ~/.aliases file in my zsh with oh-my-zsh installation. The documentation suggested that aliases/functions/ etc. should go in .oh-my-zsh/custom/ as files with a .zsh extension.

I can make a file of aliases there using the keyword "alias" as normal. However, when I try making a file with the line "source ~/.aliases" -- this does not work.

What is the best way to go about this? Should I ditch the recommendation to use the oh-my-zsh/custom/ folder and instead source from .zshrc ?

Elfen Dew

Posted 2017-11-23T15:43:07.453

Reputation: 51

Answers

4

My understanding is that you are trying to add your custom file aliases.zsh to the directory .oh-my-zsh/custom/

I just did this and tried using one of the aliases I defined in the file and it worked. Just make sure you restart your terminal's session and have the correct alias formatting alias zshconfig="mate ~/.zshrc"

Harout360

Posted 2017-11-23T15:43:07.453

Reputation: 141

I was trying to make an aliases.zsh file that consisted of a single line "source ~/.aliases" – Elfen Dew – 2018-05-24T04:16:29.347

1I want to keep my alias dotfile ~/.aliases and have zsh source this file. I could only accomplish this by adding "source ~/.aliases" to the .zshrc file, but I was trying to follow the recommended format for adding custom aliases with oh-my-zsh. The reason I was doing it this way is because I wanted a single .aliases file independent of what shell I'm using. – Elfen Dew – 2018-05-24T04:21:17.230

1

You should just symlink your main file in the custom dir.

ln -s ~/.aliases ~/.oh-my-zsh/custom/aliases.zsh

Simon

Posted 2017-11-23T15:43:07.453

Reputation: 11