command-line-interface - 术语 '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。
解决方案
您发布的屏幕截图显示了如何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
推荐阅读
- html - 使用多个模式关闭 Blazor 模式
- java - 使用 Java 序列化从文件中读取对象时出现问题
- numpy - 在行轴中查找矩阵的最大值并将其他值替换为零
- android - 如何从 Room 数据库中获取一项?
- python - 在 Tkinter 应用程序的右上角粘贴标签
- android - 使用 firebase 回收器适配器读取复杂和嵌套的 firebase 实时数据库
- reactjs - Openlayers geojson-vt 集成问题
- python - 使用来自另一个“Pandas 数据框”的标准迭代“Pandas 数据框”?
- python-3.x - 当我在 VSCode 中运行模块“http.client”时,它没有属性“HTTPSConnection”
- mysql - 过滤日期列mysql