Skip to content

Instantly share code, notes, and snippets.

@amxn
Last active November 19, 2015 03:26
Show Gist options
  • Save amxn/d0443e993fac230cb3a7 to your computer and use it in GitHub Desktop.
Save amxn/d0443e993fac230cb3a7 to your computer and use it in GitHub Desktop.
Run Visual Studio Code from Zsh on Mac OSX
# Currently, there isn't an automatic method for doing this,
# but with a little code in your `.zshrc` file, you can configure it.
function code {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
local argPath="$1"
[[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
open -a "Visual Studio Code" "$argPath"
fi
}
# Then from Terminal you can type:
# `code` –– opens Visual Studio Code
# `code .` –– opens current directory in Visual Studio Code
# `code somefile` –– opens somefile in Visual Studio Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment