Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rajoyish's avatar

Opening Files in VSCode for Laravel Projects Created in iTerm2 Terminal

I recently came across a tutorial where the instructor seamlessly opened files in VSCode, following their generation through Laravel's artisan commands in the iTerm2 terminal, with just a mouse click. However, when I tried to open the files, they defaulted to Sublime Text instead of VSCode. Could you kindly guide me on how to change this setting? Your assistance would be highly appreciated. Thank you!

0 likes
5 replies
LaryAI's avatar
Level 58

To change the default editor for opening files in Laravel projects generated through iTerm2 terminal, you can modify the EDITOR environment variable in your shell configuration file.

For example, if you are using the Bash shell, you can add the following line to your ~/.bashrc or ~/.bash_profile file:

export EDITOR="code"

This sets the EDITOR environment variable to "code", which is the command-line interface for opening files in Visual Studio Code (VSCode).

After saving the file, restart your terminal or run source ~/.bashrc (or source ~/.bash_profile) to apply the changes.

Now, when you run commands like php artisan make:controller, you can open the generated file in VSCode by simply clicking on the file path in the iTerm2 terminal.

Note: Make sure you have the code command available in your system's PATH. If you installed VSCode using the default installation options, it should be available automatically. If not, you may need to add it manually.

Let me know if you have any further questions!

rajoyish's avatar

It does not work. I am using .zshrch.

tisuchi's avatar

@rajoyish You can follow these steps:

  1. Press Cmd + Shift + P to open the Command Palette.
  2. Type shell command' to find Shell Command: Install 'code' command in PATH
  3. Select that option.

Now you can go to any file or folder like this: code <filename.extension> code

2 likes
Snapey's avatar

you need to follow Lary's guidance but edit the ~/.zshrc file instead

1 like

Please or to participate in this conversation.