How to specify my own path for my .zshrc file?

I am trying to move .zshrc to a folder where I keep such files synchronized with Github.

But now, when I start the zsh session, it does not use this configuration file.

Assuming I changed the file to ~ / .dotfiles, how can I add ~ / .dotfiles / .zshrc to PATH (?!) To make zsh with this configuration?

Executing the source ~. / Dotfiles / .zshrc only works for this session. Doesn't work anymore if I close the terminal.

+6
source share
5 answers

You can symlink :

 ln -s /path/to/original /path/to/symlink 

For zshrc you can do something like:

 ln -s ~/.dotiles/.zshrc ~/.zshrc 
+9
source

One alternative to a symlink is to put this in ~/.zshenv :

 ZDOTDIR=~/.dotfiles 

If you want .zshenv in ~/.dotfiles , you can look in the ZDOTDIR configuration in one of the global configuration files ( /etc/zshenv is a good choice).

+6
source

Alternatively, you can do what I do and use the GNU Stow. I have dotfiles in the repository, one subdirectory for each category, for example:

 dotfilerepo/zsh/.zshrc dotfilerepo/zsh/.zlogin dotfilerepo/git/.gitconfig dotfilerepo/vim/.vimrc 

then I can cd into repo and make stow zsh , and it will create a symlink from ~ / .zshrc to repo / zsh / .zshrc, another from zsh / .zlogin to ~ / .zlogin. stow vim to create symbolic links from the vim subdirectory to ~ etc.

I have a script, install-linkfarm that executes all the stow commands, so when I switch to a new machine, I clone my repo, cd to it and run install-linkfarm and fine.

+3
source

You can put this in ~/.zshrc , even as its contents:

 if [ -r ~/.dotfiles/.zshrc ]; then source ~/.dotfiles/.zshrc fi 
0
source

Here is an interesting hack that does not require the use of symbolic links. Your .xsession (or. * Wmrc) has the following:

  xterm -e 'zsh -c ". ~ / .dotfiles / .zshrc; zsh"'. 

instead of just:

  xterm 
Be sure to put -e at the end after all of your other xterm options.
-1
source

Source: https://habr.com/ru/post/1209920/


All Articles