Try this one
Open Visual Studio Code and press Command + Shift + P or F1 then type Shell
in command palette now you are able to find this option like Shell Command : Install code in PATH
from suggested list in command palette. Select that options.
That's it.
Now open your terminal type.
$ code .
To make this change persist after restart on MacOS
Many Mac users find this is forgotten and needs to be re-applied after any restart. This may happen if MacOS has applied the quarantine attribute to VS Code, which the OS uses for the "Are you sure?" notice applied on first using apps downloaded from the internet.
To check if this attribute is applied, look for com.apple.quarantine
in the list returned by this command (changing the path if that's not where you installed it):
xattr "/Applications/Visual Studio Code.app"
If that does return com.apple.quarantine
, you can remove the attribute using the same command with the -d
flag (alongside -r
to recursively remove it from all contained files and sudo
to allow the change):
sudo xattr -r -d com.apple.quarantine "/Applications/Visual Studio Code.app"
...then do Shell Command : Install code in PATH
as above after the attribute has been removed, and it should persist after restart.
Credit: derflounder.wordpress.com article linked to by RicardoVallejo in this comment.
$ source ~/.bashrc
. I would suggest you to source the.bashrc
from~/.bash_profile
. – sarbbottamOS X
you would generally add that to your~/.bash_profile
— not~/.bashrc
then restartTerminal.app
or source it like mentioned. – l'L'l