配置powershell

参考视频:

配置终端代理:

$env:HTTP_PROXY="http://127.0.0.1:10809";$env:HTTPS_PROXY="https://127.0.0.1:10809"

安装scoop

iwr -useb get.scoop.sh | iex

非管理员模式运行ps

scoop的默认安全策略使得它不能直接在管理员模式下安装;
运行以下两个命令:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
scoop install curl sudo jq

通过scoop安装neovim

scoop install neovim gcc
mkdir .config/powershell
# 配置文件位置
nvim $HOME/.config/powershell/user_profile.ps1

设置以下别名

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt Paradox

Set-Alias vim nvim
Set-Alias ll ls
Set-Alias g git
Set-Alias grep findstr
Set-Alias tig D:\zzk\sdk\Git\usr\bin\tig.exe
Set-Alias less D:\zzk\sdk\Git\usr\bin\less.exe

打开ps配置文件:

nvim $PROFILE.CurrentUserCurrentHost
# 实际上是这个目录
# Documents\WindowsPowerShell

让ps自动加载你的配置文件:

. $env:USERPROFILE\.config\powershell\user_profile.ps1
nvim $HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Install-Module posh-git -Scope CurrentUser -Force
Install-Module oh-my-posh -Scope CurrentUser -Force

不在支持通过ps模块的方式安装 oh-my-posh

链接

安装oh-my-posh这部分有比较大的变化;

装node-js的部分跳过;

z - 目录跳转;

Install-Module -Name z -Force

不知道为啥会报错;

PSReadLine: ps的自动补全;

Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck
Set-PSReadLineOption -PredictionSource History

好像安装了 PSReadLine 直接执行以下命令也可以;

Set-PSReadLineOption -PredictionViewStyle ListView

ps上的模糊搜索:
fzf

posted @ 2024-02-18 20:52  潜行1  阅读(106)  评论(0)    收藏  举报