# 插件
為了讓 pwsh 更好用,我們需要安裝一些 powershell的插件,運行下面命令進行安裝:
```
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Set-ExecutionPolicy remotesigned
```
## PowerShell 的彩色文件列表
```
Install-Module DirColors -Scope CurrentUser
Install-Module -AllowClobber Get-ChildItemColor -Scope AllUsers
```
## 增強 git 功能
```
# 一個用于 Git 的 PowerShell 環境
Install-Module -Name posh-git -Scope AllUsers -AllowPrerelease -Force
# working with SSH connections within PowerShell.
Install-Module posh-sshell -Scope AllUsers
# Oh My Zsh's Git aliases for PowerShell
Install-Module -Name git-aliases -Scope AllUsers
```
## 美化 powershell
```
Install-Module -Name oh-my-posh -Scope AllUsers
```
## powershell 增強
```
Install-Module -Name PSReadLine -AllowPrerelease -Scope AllUsers -Force -SkipPublisherCheck
```
## 系統信息輸出
```
Install-Module windows-screenfetch -Scope AllUsers -AllowClobber
Install-Module -Name InstallModuleFromGitHub -Scope AllUsers
```
## windows-screenfetch
```
Install-Module -Name windows-screenfetch
```
```
Install-Module TabExpansionPlusPlus -Scope AllUsers -AllowClobber
```
# 啟動時加載插件
為了啟動時加載插件,我們需要創建一個 `Microsoft.PowerShell\_profile.ps1`文件,放到 C:\\Users\\自己的用戶名\\Documents\\PowerShell目錄下,文件內容為:
```
#Get-PSReadLineOption # 顯示所有可以配置的選項
#Get-PSReadLineKeyHandler # 顯示所有可以配置的快捷鍵
Import-Module posh-git
Import-Module posh-sshell
Import-Module oh-my-posh
Import-Module git-aliases -DisableNameChecking
Import-Module PSReadLine
Import-Module DirColors
Import-Module InstallModuleFromGitHub
Import-Module Get-ChildItemColor
neofetch
Set-PoshPrompt -Theme Material # 設置主題為 Material
Set-PSReadlineKeyHandler -Key Tab -Function Complete # 設置 Tab 鍵補全
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete # 設置 Ctrl+d 為菜單補全和 Intellisense
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 設置 Ctrl+z 為撤銷
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 設置向上鍵為后向搜索歷史記錄
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # 設置向下鍵為前向搜索歷史紀錄
```