How to open folders or files in Visual Studio Code from the terminal in 1 single step free of hassle

How to open visual studio code from terminal

You are here because you probably tried to open a file from the terminal using vscode like this:

code my-file.json

and the response you get is that the command doesn’t exist even though you have vscode installed.

Let’s fix this by adding a new alias so that our terminal knows about this command.

No matter what you are using: zsh, bashrc or others, just edit the config file (e.g. for zsh is ~/.zshrc) and add the following line:

Alias that leads to the Visual Studio Code install path

alias code="open -a /Applications/Visual\ Studio\ Code.app"

Let’s explain:

  • alias command in the config lets you define a custom command that the terminal will recognize and run the action you specify in the commas. In this case we are opening the file in vscode editor.

If you have any question, don’t hesitate to leave it in bellow comment section and we’ll help you out!

If you haven’t ever used vscode, make sure to check the official getting started articles.

Upcoming competitors arise, fleet is coming from Jetbrain.

Leave a Reply

Your email address will not be published.

Let's connect

Stay up to date