Power Shell 配置文件:
C:\Users\wach\Documents\PowerShell\Microsoft.PowerShell_profile.ps1# ---------------------------------------------------------------------------- # # 初始化设置 # # ---------------------------------------------------------------------------- # oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/montys.omp.json" | Invoke-Expression # ------------------------------------ END ----------------------------------- # # ---------------------------------------------------------------------------- # # 导入第三方模块 # # ---------------------------------------------------------------------------- # # 导入 posh-git Import-Module posh-git # 导入 PSCompletions Import-Module PSCompletions # ------------------------------------ END ----------------------------------- # # ---------------------------------------------------------------------------- # # PSReadLine 命令行配置 # # ---------------------------------------------------------------------------- # # 提示文本颜色 Set-PSReadLineOption -Colors @{ InlinePrediction = '#8A0303'} # 设置列表视图模式 Set-PSReadLineOption -PredictionViewStyle ListView # 设置预测文本来源为历史记录 Set-PSReadLineOption -PredictionSource History # 每次回溯输入历史,光标定位于输入内容末尾 Set-PSReadLineOption -HistorySearchCursorMovesToEnd # ------------------------------------ END ----------------------------------- # # ---------------------------------------------------------------------------- # # 设置常用的快捷键 # # ---------------------------------------------------------------------------- # # 设置 Tab 为菜单补全和 Intellisense Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete # 设置 Ctrl+d 为退出 PowerShell Set-PSReadlineKeyHandler -Key "Ctrl+d" -Function ViExit # 设置 Ctrl+z 为撤销 Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 设置向上键为后向搜索历史记录 Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向下键为前向搜索历史纪录 Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # ------------------------------------ END ----------------------------------- # # ---------------------------------------------------------------------------- # # 常用命令别名设置 # # ---------------------------------------------------------------------------- # ###### notepad Set-Alias -Name note -Value notepad ###### power shell Function ochHanlder { notepad C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt } Set-Alias -Name och -Value ochHanlder ###### npm Function nvHanlder { node -v } Set-Alias -Name n -Value nvHanlder Function nlHanlder { npm list -g --depth=0 } Set-Alias -Name nl -Value nlHanlder Function ndHanlder { npm run dev } Set-Alias -Name nd -Value ndHanlder Function nbHanlder { npm run build } Set-Alias -Name nb -Value nbHanlder Function npHanlder { npm run preview } Set-Alias -Name np -Value npHanlder Function neHanlder { npm run eslint } Set-Alias -Name ne -Value neHanlder Function nfHanlder { npm run format } Set-Alias -Name nf -Value nfHanlder ###### pnpm Function piHanlder { pnpm install } Set-Alias -Name pi -Value piHanlder Function pdHanlder { pnpm dev } Set-Alias -Name pd -Value pdHanlder Function pbHanlder { pnpm build } Set-Alias -Name pb -Value pbHanlder Function ppHanlder { pnpm preview } Set-Alias -Name pp -Value ppHanlder Function peHanlder { pnpm eslint } Set-Alias -Name pe -Value peHanlder Function pfHanlder { pnpm format } Set-Alias -Name pf -Value pfHanlder ###### yarn Function yiHanlder { yarn install } Set-Alias -Name yi -Value yiHanlder Function ydHanlder { yarn dev } Set-Alias -Name yd -Value ydHanlder Function ybHanlder { yarn build } Set-Alias -Name yb -Value ybHanlder Function ypHanlder { yarn preview } Set-Alias -Name yp -Value ypHanlder Function yeHanlder { yarn eslint } Set-Alias -Name ye -Value yeHanlder Function yfHanlder { yarn format } Set-Alias -Name yf -Value yfHanlder # ------------------------------------ END ----------------------------------- #
【Windows】PowerShell 配置 oh my posh
本原创文章未经允许不得转载 | 当前页面:坏蛋格鲁 » 【Windows】PowerShell 配置 oh my posh
坏蛋格鲁