Unable to launch app using "open" command in Terminal

I have recently started using Terminal.app a lot. I figured that open command will be helpful in opening files like HTML, CSS files etc.

I have tried Visual Studio Code app from Microsoft. The app itself is running fine without installation. The problem is when I use command: open -a and press tab, the app Visual Studio Code does not appear.

I wonder if there is a way to install the app correctly? I read man open command depends on LaunchServices, and I can't find a way to register the app with this service.


The argument(s) to open -a command can be Tab autocompleted, if you specify the path from the parent directory, e.g. open -a /Applications.

Try running the following command-line to launch Visual Studio Code from Terminal:

open -a "Visual Studio Code"

To open a file named index.html with Visual Studio Code app using open command, type:

open -a "Visual Studio Code" index.html

Please note you need to enclose the name of the app which contains spaces into double-quotes.

Additionally, quoting from the man page:

The open command opens a file (or a directory or URL), just as if you had double-clicked the file's icon. If no application name is specified, the default application as determined via LaunchServices is used to open the specified files.

The statement is referring to the case when you are attempting to open a file using the open command. To launch an app, the syntax is simply open command followed by space, followed by -a flag, another space then the name of the app (enclosed in " if the name contains spaces).

If you have not installed the app already, you should install it by copying the Visual Studio Code.app bundle into /Applications directory.