How to run Visual Studio Code from the command line?

In order to have code open Visual Studio Code from the terminal, you need to add it to the PATH by starting it (from the Launchpad, or Applications), then open its command palette by entering cmd + shift + P. A little text box you can type into will pop up near the top of the window. Type in "shell command" and with the arrow keys you should navigate to the option that says Install 'code' command in PATH and press ENTER.

Now you can cd into a directory and do code . to open VS Code with that directory as the working project directory.

You might need to close and reopen your terminal in order for your shell to use the new alias.