I'm currently trying to write a shell function for updating my .zshrc file. I currently have an alias that is as follows

alias zshrc="vim ~/.zshrc"

I was wondering if there is any way to write a function that would wait for me to close vim then run a command after vim has closed. For reference the command I would want to run is.

source ~/.zshrc
  • Just right a normal function, with the commands you want to run after vim included. The subsequent commands will not run until vim has been closed by default.
    – Jaken551
    Jul 8, 2018 at 21:34
  • 1
    can zsh aliases not include a ; or &&? alias zshrc='vim ~/.zshrc; source ~/.zshrc'? Jul 9, 2018 at 1:26
  • @glennjackman Yes, they can. Aliases are expanded before the command line is parsed. So they can contain anything you otherwise could type on the command line because they are replaced by their value as if you had typed it on the command line.
    – Adaephon
    Jul 10, 2018 at 9:25

1 Answer 1


To run one command after another, simply write them on separate lines, or with ; after the first command. So change your alias to a function, and make it run source ~/.zshrc after vim has finished running.

function zshrc {
  vim ~/.zshrc
  source ~/.zshrc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .