I want to use Notepad++ instead of Notepad to edit my Pod configurations in Kubernetes.
kubectl edit pods my-pod
I tried to change the EDITOR environment variable, but I am getting all kinds of errors and none of it is working.
- I tried manually adding the EDITOR environment variable using the GUI.
- I tried adding it via command line –
[System.Environment]::SetEnvironmentVariable("EDITOR", "C:Program FilesNotepad++notepad++.exe", "User")
- I tried adding it in my Powershell profile like:
$env:EDITOR = "C:Program FilesNotepad++notepad++.exe"
I tried encapsulating my command within "
or '"
. Nothing seems to work.
I’m getting errors like:
‘C:Program’ is not recognized as an internal or external command,
or
‘”C:Program FilesNotepad++notepad++.exe”‘ is not recognized as an internal or external command,
What is the correct syntax to do this ?
OS: Windows 11 Enterprise 23H2
3
It looks like kubectl
assumes that the executable file path specified via the EDITOR
environment variable contains no spaces and that any attempt to use such paths via embedded quoting doesn’t work, as this result in quoting/escaping of these quotes (strangely, seemingly using POSIX-shell syntax).
Thus, the solution should be to use the short (8.3) version of your path, which you can obtain as follows (should work analogously with your [System.Environment]::SetEnvironmentVariable()
call):
$env:EDITOR =
(New-Object -ComObject Scripting.FileSystemObject).GetFile('C:Program Filesnodejsnode.exe').ShortPath
1