[英]kubectl exec command not working from powershell ISE (works from powershell) - Is there a reason or workaround to make it work?
[英]kubectl alias and autocomplete not working for powershell
尝试在 Windows Server 2022 上使用Windows PowerShell
和PowerShell Core
使kubectl
的自动完成功能与别名k
一起使用,但无法使其正常工作
测试了
echo 'Set-Alias -Name k -Value kubectl' >> $PROFILE
kubectl completion powershell >> $PROFILE
或者甚至只是尝试让它在同一个 session 中工作,而不用担心将其保存到 PowerShell 配置文件
Set-Alias -Name k -Value kubectl
kubectl completion powershell | Out-String | Invoke-Expression
到目前为止的结果:
Powershell 5.1
使用kubectl
完成制表符: OK
使用k
完成制表符:失败
Powershell 核心 7.3
使用kubectl
完成制表符:失败
使用k
完成制表符:失败
上面的结果是用Windows Terminal
和cmd
测试的
我错过了一些明显的东西吗? (就像我平时做的那样)
谢谢!
所以 go 它在 PowerShell 5.1 上工作,并假设 Cobra 只在 Powershell 5.x 上工作,所以放弃让 PowerShell 核心工作!
# Powershell 5.x
echo 'Set-Alias -Name k -Value kubectl' >> $PROFILE
echo 'Register-ArgumentCompleter -CommandName k -ScriptBlock $__kubectlCompleterBlock' >> $PROFILE
kubectl completion powershell >> $PROFILE
# Reload the PowerShell profile
. $PROFILE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.