Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.12 KB

vscode-as-git-editor.md

File metadata and controls

40 lines (31 loc) · 1.12 KB

Using VS Code as git editor when using the integrated terminal

If you run export EDITOR=code in the integrated terminal, VS Code will correctly be used as the editor for that shell session - so e.g. your git commits can be authored in vscode.

That is just a bit annoying to have to do on every new session or tab.

In order to get around it, I added the following configuration to my main user-settings.json file in vscode.

{
  //...
  "terminal.integrated.env.osx": {
    "GUSTAVNIKOLAJ_VSCODE": "yes"
  },
  "terminal.integrated.env.linux": {
    "GUSTAVNIKOLAJ_VSCODE": "yes"
  },
  // ...
}

That will make VS Code's integrated terminal set an environment variable in the shells that it starts. I can then use that environment variable to conditionally alter my EDITOR variable.

if ! [[ $GUSTAVNIKOLAJ_VSCODE == "" ]]; then
  export EDITOR="code --wait" ;
fi

For some reason, it does not work setting EDITOR directly in the vscode settings.

References