Adding "code" command line to open file and set default editor via click.

Sometimes, we want to pressing hold command + right-click to open file and typing command to opening, so how to do it?

$ code filename

vscode documentation

Adding the code command

  • Launch VS Code.
  • Open the Command Palette (Ctrl+Shift+P) and type ‘shell command’ to find the Shell Command: Install ‘code’ command in PATH command.

Set iterm default editor

  • Launch iterm.
  • Negative to (Preferences > Profiles > Advanced > Semantic History) and set editor by default, when you pressing hold and right click to opening specific file.