For running Visual Studio Code from the terminal, you need to do a few extra steps as from Running Visual Studio Code on macOS: Get Visual Studio Code up and running on Mac (macOS):
Launching from the Command Line
You can also run VS Code from the terminal by typing ‘code’ after adding it to the path:
- Launch VS Code.
- Open the Command Palette (⇧⌘P) and type ‘shell command’ to find the Shell Command: Install ‘code’ command in PATH command.

- Restart the terminal for the new
$PATH
value to take effect. You’ll be able to type ‘code .’ in any folder to start editing files in that folder.
Note: If you still have the old code
alias in your .bash_profile
(or equivalent) from an early VS Code version, remove it and replace it by executing the Shell Command: Install ‘code’ command in PATH command.
To manually add VS Code to your path:
cat << EOF >> ~/.bash_profile
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF
This is what the code
command is and does:
$ which code
/usr/local/bin/code
$ ls -alh `which code`
lrwxr-xr-x 1 jeroenp admin 68B Apr 16 13:24 /usr/local/bin/code -> /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code
$ cat `which code`
#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
function realpath() { /usr/bin/python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0"; }
CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?
–jeroen
Like this:
Like Loading...