macos – code . Not working in Command Line for Visual Studio Code on OSX/Mac

macos – code . Not working in Command Line for Visual Studio Code on OSX/Mac

1. Make sure you drag Visual Studio Code app into the -Applications- folder

Otherwise (as noted in the comments) youll have to go through this process again after reboot


2. Next, open Visual Studio Code

Open the Command Palette via (⇧⌘P) and type shell command to find the Shell Command:

Update: use Uninstall code command in PATH** command before

> Install code command in PATH** command.

![Command

After executing the command, restart the terminal for the new $PATH
value to take effect. Youll be able to simply type code . in any
folder to start editing files in that folder. The . Simply means current directory

(Source: VS Code documentation)


NOTE: If youre running a build based off the OSS repository… You will need to run code-oss . @Dzeimsas Zvirblis

If you want to add it permanently:

Add this to your ~/.bash_profile, or to ~/.zshrc if you are running MacOS Catalina or later.

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

source: https://code.visualstudio.com/docs/setup/mac

macos – code . Not working in Command Line for Visual Studio Code on OSX/Mac

Open the ~/.bashrc file using vi/vim
$ vi ~/.bashrc

Enter the following by pressing i to insert:

code () { VSCODE_CWD=$PWD open -n -b com.microsoft.VSCode --args $* ;}

Save the file using :wq

Reflect the settings in ~/.bashrc using the following command:

source ~/.bashrc

Leave a Reply

Your email address will not be published.