Skip to content

Instantly share code, notes, and snippets.

@cdevroe
Created May 28, 2015 14:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cdevroe/4fb3ebf7806b39020c33 to your computer and use it in GitHub Desktop.
Save cdevroe/4fb3ebf7806b39020c33 to your computer and use it in GitHub Desktop.
Open Visual Studio Code from Terminal
code () {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code" -n
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
open -a "Visual Studio Code" -n --args "$F"
fi
}
@cdevroe
Copy link
Author

cdevroe commented May 28, 2015

Add this to ~/.bashrc

code -- opens Visual Studio Code
code . -- opens current directory in Visual Studio Code
code somefile -- opens somefile in Visual Studio Code

Inspired by http://kevgriffin.com/how-to-run-visual-studio-code-from-terminal-on-mac-osx/

The only thing I added to my script was that Code will open a new window each time so that you can open multiple projects at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment