3 ms·
> Use alias to edit and reload .zshrc > source $HOME/.zshrc .zshrc isn't the only startup file, if you place everything there you're likely doing it wrong and
by oefrha 6y ago
> Use alias to edit and reload .zshrc
> source $HOME/.zshrc
.zshrc isn't the only startup file, if you place everything there you're likely doing it wrong and should split things like some environment settings to $ZDOTDIR/.zshenv.
Better way to reload startup changes:
alias reload='exec zsh -l'
- thorstenhans 6y agoGood point. Separation of different config aspects is in the pipe as dedicated article
- yNeolh 6y agoI tend to use: alias reload="exec -l $SHELL" Which I copied from somewhere, I don't know how specific it is but maybe it helps someone :)
- oefrha 6y agoUsing $SHELL is not great because it is not a reliable env var. It's only set for login shells, and if your login shell isn't zsh you'll get a different shell on this "reload". (A long time ago I had an account somewhere where my sysadmin didn't respond to chsh request for whatever reason, so my login shell remained /bin/bash while I actually used zsh day to day.) It can also be anything, really: export SHELL=/sbin/nologin # or /usr/sbin/nologin, or equivalent on your system exec -l $SHELL You want zsh, so just use zsh. As for -l, exec zsh -l and exec -l zsh both replace the current shell with a login zsh, so they are effectively the same.
- e_proxus 6y agoI have this reminder in every `~/.z*` file: # Load Order Interactive Interactive Script # Startup Only login Always # ------------- ----------- ----------- ------ # /etc/zshenv 1 1 1 # ~/.zshenv 2 2 2 # /etc/zprofile 3 # ~/.zprofile 4 # /etc/zshrc 5 3 # ~/.zshrc 6 4 # /etc/zlogin 7 # ~/.zlogin 8 # # Shutdown # ------------- ----------- ----------- ------ # ~/.zlogout 9 # /etc/zlogout 10 # # Note: ZSH seems to read ~/.profile as well, if ~/.zshrc is not present.
- masklinn 6y ago> ~/.zshenv Technically it's $ZDOTDIR/… Also note from the official documentation: > `.zprofile' is meant as an alternative to `.zlogin' for ksh fans; the two are not intended to be used together