I want to edit a service using the following command in (Windows 10) powershell:
> oc edit service helloworld -o json
This opens notepad as the editor to edit the file. I do however want to open it in an editor with syntax highlighting.
I've found the following in the documentation:
This would result in the following command. I've added sublime text 3 to my path, but when I run the command:
> OC_EDITOR="subl" oc edit service helloworld -o json
the output is:
OC_EDITOR=subl : The term 'OC_EDITOR=subl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I've tried all types of variations, e.g. with/without quotes, sublime_text, but they don't seem to work.
Running subl or sublime_text from the command line simply opens sublime text 3.
The screenshot that you've posted shows directions for how to override the oc
editor on a Bash (linux shell) cli by setting an environment variable that applies to that command only.
I'm not overly familiar with Powershell, but I would assume the same logic should apply. If you create a OC_EDITOR
environment variable in your Powershell session, it should allow oc edit
to your Sublime Text editor.
Set-Item -Path Env:OC_EDITOR -Value subl
You can confirm that this is set via
Get-ChildItem Env:OC_EDITOR
Now, I don't have my oc
tools installed on a Windows machine to test this, but it should work.
Powershell reference: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables