open visual studio code from terminal mac 1

open visual studio code from terminal mac

#Add Bash alias in .bash_profile ?
$ alias code="open -a /Applications/Visual\ Studio\ Code.app"

#Open Visual Studio Code by command
$ code .

Here is what the above code is Doing:
1. The alias command creates a new alias for the command that follows it.
2. The open command opens the file or directory that follows it.
3. The -a flag tells open to open the file with the specified application.
4. The \ character tells the shell to ignore the following character.
5. The \ character is necessary because the space character is used to separate arguments.
6. The . tells open to open the current directory.

Similar Posts