
我見過這個問題這不完全是一回事。我安裝了 Powershell Core 6。我通常使用快捷鍵Windows+開啟 Powershell X,然後使用I。現在我想要使用該快捷方式開啟 Powershell Core 6 而不是舊的 Powershell 5。
答案1
或者只需使用新的 Windows 終端並添加您選擇的任何內容。
Windows 終端是一種新型、現代化、快速、高效、強大且高效的終端應用程序,適用於命令列工具和 shell(例如命令提示字元、PowerShell 和 WSL)的使用者。其主要功能包括多個選項卡、Unicode 和 UTF-8 字元支援、GPU 加速文字渲染引擎以及自訂主題、樣式和配置。
這是一個開源項目,我們歡迎社區參與。如欲參與,請訪問https://github.com/microsoft/terminal
根據迄今為止的評論進行更新。
你無法自然地做你所追求的事情。您必須破解註冊表才能更改此設定。
然而,當您只需將pwsh 快捷方式固定到工作列上的第一個位置,然後只需按任務欄上的Win 鍵+ 1(或將其放置到位置9 的位置)時,為什麼還要費盡心思呢?
例如,在我的工作列上,我的 Windows Terminal、pwsh、powershell、powershell_ISE、VSCode、PowerShellStudio 位於位置 1、2、3、4、5、6。
答案2
使用此工具可以編輯 Win+X 選單: https://winaero.com/download-winx-menu-editor-allows-you-to-add-or-remove-winx-menu-items
在這裡,有一些團體。使用新增程式按鈕將其新增至您喜歡的任何群組。然後,按下「重新啟動資源管理器」(注意:這將關閉所有檔案總管視窗!)
答案3
@vssher 建議的另一個選擇是使用康埃穆或者微軟終端。
設定為預設終端:
- 微軟終端機: Windows 的設定→隱私與安全→對於開發人員→終端
- 康埃穆設定:
+ Alt+ P→一體化→預設期限:
- 強制 ConEmu 作為控制台應用程式的預設終端
主開關 - 在作業系統啟動時註冊
透過註冊表登入時自動啟動 - 攻擊模式
掛鉤新程序不需要正在運行的 ConEmu 實例,一個已掛鉤的進程 [explorer.exe
] 就足夠了 - 掛鉤的可執行檔或視窗類別名稱的列表:
explorer.exe
ConEmu 透過以下方式設定為預設終端鉤子內Windows外殼[explorer.exe
] 和/或任何其他程序,透過|
[pipe] 分隔:
(Windows 的「設定」應用程式與因掛鉤而將 ConEmu 設定為預設作業系統終端無關)explorer.exe|devenv.exe|totalcmd.exe|TaskManagerWindow|codeblocks.exe|lazarus.exe|gdb.exe
- 強制 ConEmu 作為控制台應用程式的預設終端
Pwsh.exe
要配置在 ConEmu 中啟動的熱鍵:
- 設定→啟動→任務:預定義任務(命令組)
- +圖示或使用 ConEmu 的預設 [
Shells::PowerShell Core
]- 姓名 (顯示
Group <#>
):Powershell::Pwsh
- 熱鍵:選擇您想要的任何內容
- 新控制台的預設任務:開啟 ConEmu 時的預設 shell
- 工作列跳轉清單:將此任務新增至 ConEmu 工作列跳轉列表
- 預設外殼(Win+X):
- Windows 10:使其成為Win+X選單中的預設值
- Windows 11:不影響Win+X菜單
- 雖然Win+X選單也可以在 Win <11 中手動修改,但它會在 11 中導致損壞(如果有人知道不會導致損壞的方法,請發表評論,我會對此進行修改)
- 任務參數:不需要,但可以定制
- 命令:
pwsh.exe -NoExit -Command "Import-Module C:\Users\<username>\WindowsPowerShell\profile.ps1" -new_console:t:"Pwsh"
- 若要作為管理終端啟動,請
a:
在先前新增t:
:-new_console:a:t:"Pwsh"
-Import-Module
是可選的,但允許自訂提示profile.ps1
:# # =========================================================== ##::[[--- Powershell PS1 Profile ---]]::## # =========================================================== # Microsoft.PowerShell_profile.ps1 || Profile.ps1: # %UserProfile%\Documents\WindowsPowerShell # $env:UserProfile\Documents\WindowsPowerShell # ================================================================ # Variables #---------------------------------------------------------------- # ANSI: $ESC = [char]27 # Host.PrivateData: $PD = $($Host.PrivateData) # Colors: $Host.UI.RawUI.BackgroundColor = ($bckgrnd = 'Black') $Host.UI.RawUI.ForegroundColor = 'Gray' $PD.ErrorForegroundColor = 'Red' $PD.ErrorBackgroundColor = $bckgrnd $PD.WarningForegroundColor = 'Magenta' $PD.WarningBackgroundColor = $bckgrnd $PD.DebugForegroundColor = 'Yellow' $PD.DebugBackgroundColor = $bckgrnd $PD.VerboseForegroundColor = 'Green' $PD.VerboseBackgroundColor = $bckgrnd $PD.ProgressForegroundColor = 'Yellow' $PD.ProgressBackgroundColor = $bckgrnd #================================================================ # Functions #---------------------------------------------------------------- # Prompt: Function set-prompt { Param ( [Parameter(Position=0)] [ValidateSet("Default","Test")] $Action ) switch ($Action) { "Default" { Function global:prompt { if (test-path variable:/PSDebugContext) { '[DBG]: ' } write-host " " write-host ("$ESC[48;2;40;40;40m$ESC[38;2;170;210;0m$(Get-Location) $ESC[0m $ESC[0m") if ( $host.UI.RawUI.WindowTitle -match "Administrator" ) { $Host.UI.RawUI.ForegroundColor = 'Red' $(if ($nestedpromptlevel -ge 1) { write-host ('PS $$ ') -ForegroundColor Red -NoNewLine } else { write-host ('PS $ ') -ForegroundColor Red -NoNewLine }) } else { $(if ($nestedpromptlevel -ge 1) { write-host ('PS $$ ') -ForegroundColor Blue -NoNewLine } else { write-host ('PS $ ') -ForegroundColor Blue -NoNewLine }) } return " " } } } } set-prompt Default # Relaunch as Admin: function Relaunch-Admin { Start-Process -Verb RunAs wt } Set-Alias psa Relaunch-Admin
- 若要作為管理終端啟動,請
- 姓名 (顯示
- Save settings
要導入ConEmu.xml
我使用的配置:
答案4
這是我目前正在使用的解決方法。
如果您使用PowerShell $PROFILE
,您可以插入一行pwsh.exe
,則可以在腳本的開頭。任何用於啟動 PowerShell 的 Windows 捷徑都會有效地掛接到電源外殼 6間接作為子進程電源外殼5。