by latexr · 1y ago · 0 comments
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. 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' 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.