3 ms·
> When I create, update, or delete an alias, I have to reload my `.zshrc`. Only if you need the change to be available immediately in the tab you’re on. Which
by latexr 2y ago
> When I create, update, or delete an alias, I have to reload my `.zshrc`.
Only if you need the change to be available immediately in the tab you’re on. Which you can ensure, appropriately, with an alias:
alias z='"${EDITOR}" ~/.zshrc && source ~/.zshrc'
Now executing `z` will open your `.zshrc` in your default editor and immediately source it afterwards.
- noahjk 2y agoHere's what I use in my .zshrc with VS Code: alias reload="source ~/.zshrc >/dev/null" alias zshconfig="code --wait --new-window ~/.zshrc && reload" the --wait flag tells zsh that it's not done executing until the window/file is closed.
- latexr 2y agoOn macOS, you can do that for any GUI editor by using the `open` command with the `-W` and `-n` flags. See `man open` for details.
- dcb_lu 2y agoI do something similar to my .bash_aliases, but with a few short additions to make sure running it multiple times doesn't have any strange side effects. For instance: function edit_load() { $EDITOR $1 source $1 if [ $? -eq 0 ] then echo "$1 updated." fi } alias aliases="edit_load ~/.bash_aliases" # to make sure I don't add things to $PATH on each reload append_path () { case ":$PATH:" in *:"$1":*) ;; \*) PATH="${PATH:+$PATH:}$1" esac } append_path '/blah/blah/bin'