vim $PROFILE.CurrentUserAllHosts
贴入
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
管理员shell执行
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
复制到管理员终端直接执行
ni -Type File -Path $PROFILE
sc -Path $PROFILE -Value '
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
'
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
创建PS的Profile文件 如果没有使用过PS相关的功能,Profile文件应该是没有的。下面是创建命令
ni -Type File -Path $PROFILE 写入命令 打开Profile文件写入下列命令
Set-PSReadLineOption -HistorySearchCursorMovesToEnd Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward 脚本权限控制 一般默认的用户权限是Undefined,是没有办法执行脚本文件的。
我们需要通过设置更高的权限来运行我们的脚本。
Get-ExecutionPolicy -List
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser 这是权限相关的文档。 https://docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.core/about/about_execution_policies
最后 重启PowerShell窗口,或者打开新的。