Setting VSCode as my Mac M1's default editor for Git

Viewed 1221

Recently got an M1 and I'm trying to wrap my head around the default shell zsh. First thing I tried was the usual line as of with bash:

git config --global core.editor "code -w"

This line used to work in the past like charm but not anymore, now I get this error over and over.

hint: Waiting for your editor to close the file... code -w: code: command not found
error: There was a problem with the editor 'code -w'.

Then I tried to add the line export EDITOR="code -w" to ~/.zshrc and even follow the steps to install in vscode from shell command: Install 'code' in command PATH but it obviously install all dependencies in bash not zsh.

I've searched everywhere how to configure vsc on the new M1 model and I have not found anything related to it.

If anyone can shed some light on how to do it that would be highly appreciated. It would also be nice to have VSC as my default text editor in general, not only for Git but for everything.

2 Answers

If you're using Visual Studio Code - Insiders, you can try the following git command

git config --global core.editor 'code-insiders --wait'

or

git config --global core.editor 'code-insiders -w'

If you are running into the similar error above after running the above git command, try entering shell to filter some shell commands like Install 'code-insiders' command in PATH or Uninstall 'code-insiders' command from PATH to add or remove code-insiders from PATH after opening command platte by entering ctrl + shift + p(or command + shift + p)

By the way, Setting VSCode as default editor for Git is a better choice after installing GitLens extension.

As you have seen, this works:

 git config --global core.editor "/usr/local/bin/code"

But you might also consider installing (in a few days) VSCode 1.54 (Feb. 2021), with official M1 support:

Screenshot of website showing the default download for macOS

(This is still an insider build for now)

Related