[英]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.