1

I want to change the name of Visual Studio Code to vscode for using the command open -a vscode. Any idea how?

3 Answers3

2

You can make a symbolic link:

cd /Applications
ln -s Visual\ Studio\ Code.app vscode

You can then open it with:

open -a /Applications/vscode
Ortomala Lokni
  • 5,595
  • 7
  • 31
  • 58
2

When I installed VSCode on my machine it installed something for the command line. If I type the word Code, from the command line, VSCode starts up.

There is a command in the Command Palette that will do the link for you. Go to command palette, under the view menu, and there is a command that says Shell Command: Install 'code' command in PATH.Click on this and it sets up a link from Applications/vscode to /usr/local/bin. After that, you can just type code to run the program.

Natsfan
  • 14,185
  • Your answer doesn't work as advertised! I just downloaded Visual Studio Code from https://code.visualstudio.com/download and installed it (unzipped VSCode-darwin-stable.zip to /Applications), opened it and closed it. Then in Terminal typed Code and it errors with: zsh: command not found: Code – user3439894 Sep 09 '20 at 19:43
  • ok, it worked fine for me. can you try it using the bash shell? Unless you've already found an answer. I'll look to see where code is defined on my system. Maybe that will help you. – Natsfan Sep 09 '20 at 19:47
  • Shouldn't have to try bash as zsh is the default shell in a clean install of macOS Catalina, however, it too errors: -bash: Code: command not found Did you by chance create an alias or sysmlink? – user3439894 Sep 09 '20 at 19:53
  • i found a link. but in VSCode there is a command in the command palette that says: Shell Command: Install 'code' command in PATH. maybe that's how I did it. It creates a link for you. I don't remember for sure how I did it. If I had done it manually I would not have called it code. lol. Probably vscode. Go to the View menu in VSCode and select Command Palette. Under that you'll see the command. Maybe easier to do link yourself. – Natsfan Sep 09 '20 at 20:34
0

Instead of having to make the necessary changes to be able to type open -a vscode in Terminal, why not just add the following to your ~/zprofile file, e.g.:

export PATH="/Applications/Visual Studio Code.app/Contents/Resources/app/bin:$PATH"

Then all you have to do in Terminal to open Visual Studio Code is type code and press enter.

See Launching from the command line# in Visual Studio Code on macOS for additional details.

enter image description here

user3439894
  • 58,676