microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.61k stars 276 forks source link

Set EDITOR automatically for Remote SSH #6426

Open davetapley opened 2 years ago

davetapley commented 2 years ago

I'm surprised this hasn't come up yet...

As mentioned in #643 you can set export EDITOR='code --wait' to get a nice interactive git flow (or in my case crontab -e) when using Remote SSH. Is there a reason this isn't injected automatically?

If someone is going to the trouble of using Remote SSH in VS Code (as opposed to just using ssh from a terminal outside VS Code), then I presume they'd be happy that VS Code is the default editor (as opposed to e.g. nano in the terminal window)?

RAnders00 commented 4 months ago

I wanted to share a possible solution for the meanwhile. Add this to your ~/.bashrc, ~/.zshrc etc:

if [ "$VSCODE_INJECTION" = "1" ]; then
    export EDITOR="code --wait"
fi