Skip to content

Instantly share code, notes, and snippets.

@mordr
Last active July 14, 2024 13:46
Show Gist options
  • Save mordr/3c2df494c690672247c720f66f0fb613 to your computer and use it in GitHub Desktop.
Save mordr/3c2df494c690672247c720f66f0fb613 to your computer and use it in GitHub Desktop.
Set Visual Studio Code as default editor for kubectl

Set KUBE_EDITOR to Visual Studio Code, assumes 'code' is in PATH

export KUBE_EDITOR='code --wait'

Running k edit ... will open up the yaml using Visual Studio Code.

@parveenksharma
Copy link

On my mac Ventura in my ~/.bash_profile I have :
export KUBE_EDITOR='open -a "Visual Studio Code" --wait'

and it is opening the new VSCode window with command on terminal:
kubectl edit pod fooapp

The problem is once I am done editing the yml and save it and close the associated VSCode window the control is not returning to terminal.
For that I have to Quit VSCode completely.

This is very inconvenient as this is resulting in closing all my other open / work in progress files with VSCode .

Please suggest.

@ivaylokardashev
Copy link

$env:KUBE_EDITOR="code --wait"

Thanx you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment