首页 > 解决方案 > 术语 'OC_EDITOR="subl" 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称

问题描述

我想在 (Windows 10) powershell 中使用以下命令编辑服务:

> oc edit service helloworld -o json

这将打开记事本作为编辑器来编辑文件。但是,我确实想在带有语法突出显示的编辑器中打开它。我在文档中找到了以下内容: 文档片段

这将导致以下命令。我已将 sublime text 3 添加到我的路径中,但是当我运行命令时:

> OC_EDITOR="subl" oc edit service helloworld -o json

输出是:

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.

我尝试了所有类型的变体,例如带/不带引号、sublime_text,但它们似乎不起作用。

从命令行运行 subl 或 sublime_text 只会打开 sublime text 3。

标签: command-line-interfaceopenshiftopenshift-originokd

解决方案


您发布的屏幕截图显示了如何oc通过设置仅适用于该命令的环境变量来覆盖 Bash (linux shell) cli 上的编辑器。

我对 Powershell 并不太熟悉,但我认为应该应用相同的逻辑。如果您在 Powershell 会话中创建OC_EDITOR环境变量,它应该允许oc edit您的 Sublime Text 编辑器使用。

Set-Item -Path Env:OC_EDITOR -Value subl

您可以确认这是通过

Get-ChildItem Env:OC_EDITOR

现在,我没有oc在 Windows 机器上安装我的工具来测试它,但它应该可以工作。


Powershell 参考:https ://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables


推荐阅读