Reputation: 611
I want to open Visual Studio Code with the terminal by writing code. I wrote the following line in the bash_profile
export PATH="/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin:$PATH"
So that the PATH is updated with directory where the binary code is.
Unfortunately, I still get:
tommasos-mbp:~ tommaso$ code
-bash: code: command not found
The weird thing is that the PATH have been correctly updated, indeed if a run in the terminal env
, I get:
PATH=/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin:
Also if I run directly in the terminal
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code
Visual studio code opens perfectly.
What is wrong here?
Upvotes: 4
Views: 5025
Reputation: 123
In case there is new Mac user like me, there is a build-in option in vscode where it will automatically add vscode in the PATH environment variable so that you can access code
through Terminal. Follow this Launching vscode from terminal in Mac OS documentation
Upvotes: 6
Reputation: 47169
Lose the double-quotes around your export (the path is escaped, so you don't need them). Otherwise the terminal literally interprets your path as being /Applications/Visual\ Studio ...
export PATH="/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin:$PATH"
Should be:
export PATH=/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin:$PATH
Upvotes: 4