pwsh 极致专攻
预览
环境配置
不同于 Windows 自带的 Windows PowerShell,这个 PowerShell(也叫 posh/pwsh) 需要另行安装(百度搜,安装上就行)
配置环境变量:Path 里面+
D:\Game\Demo\PowerShell\
如果用 VScode 的话,实际上不设置环境变量也行,因为在 VScode 内需要指定 powershell 路径
Scoop 安装全自动,不需要配置.
1
scoop install pwsh
安装插件
oh-my-posh
(Posh 增强主题)1
Install-Module oh-my-posh
PoshFuck
不必在意格式,复制就行
1
2Set-ExecutionPolicy RemoteSigned
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/mattparkes/PoShFuck/master/Install-TheFucker.ps1'))posh-git
(用于扩展 Posh 里的 Git 自动补全)1
Install-Module posh-git
PSReadline
(Windows 自带,可以直接使用)预测显示历史命令
上下左右高级补全
启用主题及插件
启用主题
: ~/文档/PowerShell/Microsoft.PowerShell_profile.ps1 / $profile 加上以下字段1
2
3Import-Module oh-my-posh
Import-Module posh-git
Set-PoshPrompt -Theme powerlevel10k_classicPosh中类似Linux形式补全
(按 Tab 自动补,非常实用)1
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Posh-Fuck
,类似Zsh-theFuck
- 用法:
fuck
/fuck!
/WTF
/Get-Fucked
1
Import-Module PoShFuck
- 用法:
PSReadline
1
2
3
4
5# Enable Prediction History
Set-PSReadLineOption -PredictionSource History
## Advanced Autocompletion for arrow keys
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward这个文件实际上是 PowerShell 打开时默认加载的指令集,可以自定义添加命令,如:
- 清除打开时的版本信息,在最后一行添加:
clear
- 清除打开时的版本信息,在最后一行添加:
oh-my-posh
查看所有主题
1
Get-PoshThemes
用法:
1
Set-PoshPrompt -Theme xxx
启用管理员模式
- 作用就是让右键文件时出现管理员权限
- 实际上没啥用,并不太推荐使用.
- 这个东西与上面 PowerShell 没啥关系
1 | reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Kernel" /v DisableTsx /t REG_DWORD /d 0 /f |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 ⭐️齐下无贰⭐️!
评论