1
set-executionpolicy remotesigned

安装:PSReadLine

1
Install-Module PSReadLine -RequiredVersion 2.1.0

安装posh-git

1
PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force

写入配置:

1
notepad $PROFILE

若提示错误:请继续以下代码

1
New-Item -Path $PROFILE -Type File -Force

Microsoft.PowerShell_profile.ps1 配置:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
clear
# Tab 当按Tab键时,显示所有选项的导航菜单
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
 
# 每次回溯输入历史,光标定位于输入内
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
 
# 下一条自动补全 History记录 line模式中相反
Set-PSReadlineKeyHandler -Key Ctrl+n -Function HistorySearchForward
# 上一条自动补全 History记录
Set-PSReadlineKeyHandler -Key Ctrl+p -Function HistorySearchBackward
 
# auto suggestions
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History


 # git自动补全
#Add-PoshGitToProfile
Import-Module posh-git