StarShip
记录一下win10starship
的安装
安装
按照官网的指导
软件包来源 | 指令 |
---|---|
crates.io | cargo install starship --locked |
Chocolatey | choco install starship |
conda-forge | conda install -c conda-forge starship |
Scoop | scoop install starship |
这里使用的是conda
安装,最开始使用的是cargo
,但是有个包一直编译不通过,就换成了conda
,(如果嫌麻烦,scoop
相对会更简单),使用conda
之前最好先换源,开始使用的是默认源,一直安装失败,换了清华源后好了,安装完成后,可以看到在conda
安装目录的bin
目录下,有个starship.exe
的可执行程序
shell配置
powershell
首先检查配置文件是否存在
Test-Path -Path $PROFILE.AllUsersAllHosts
说明 | 名称 |
---|---|
当前用户、当前主机 | $PROFILE |
当前用户、当前主机 | $PROFILE.CurrentUserCurrentHost |
当前用户,所有主机 | $PROFILE.CurrentUserAllHosts |
所有用户,当前主机 | $PROFILE.AllUsersCurrentHost |
所有用户,所有主机 | $PROFILE.AllUsersAllHosts |
这里根据用户进行选择配置,如果不存在,则运行以下格式的命令创建配置文件,记得将占位符的值 <profile-path>
替换为要创建的配置文件的路径,注意这里需要管理员身份
if (!(Test-Path -Path <profile-name>)) {
New-Item -ItemType File -Path <profile-name> -Force
}
使用notepad <profile-name>
编辑配置文件,注意同样需要管理员身份,在配置文件中写入
Invoke-Expression (&starship init powershell)
保存退出,并重新启动powershell
权限设置
第一次执行可能会提示
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
因为Windows下PowerShell默认的权限级别是Restricted,不允许执行PS脚本(即.ps1文件)。如果在Restricted权限级别下运行,就会得到以上的错误信息,解决方法就是以管理员身份运行powershell,将执行权限修改为RemoteSigned或者Unrestricted:
Set-ExecutionPolicy RemoteSigned
路径
修改权限后再次执行,此时提示不能将starship识别为可执行命令,将conda的bin
目录加入环境变量path
后,解决问题
再次重新启动powershell,提示加载个人及系统配置文件用了xxx毫秒,表示powershell配置完成
cmd
官网给出的方法是需要使用 Clink (v1.2.30+) 与 Cmd。
Clink combines the native Windows shell cmd.exe with the powerful command line editing features of the GNU Readline library, which provides rich completion, history, and line-editing capabilities. Readline is best known for its use in the Unix shell Bash, the standard shell for Mac OS X and many Linux distributions.
首先安装Clink
,在clink官网下载并安装好clink,在windows文件资源管理器地址行输入%LocalAppData%\clink
跳转,在该目录下,创建一个starship.lua
的文件,并写入
load(io.popen('starship init cmd'):read("*a"))()
保存,重新运行cmd,此时cmd终端将出现clink的版本号
字体配置
安装完成后,在使用中,部分字符可能无法正常使用,因为官网上要求安装一个 Nerd Font的字体,并在终端启用。
根据个人喜好安装好字体,推荐使用Windows-Terminal来完成对字体的启用,打开Windows-Terminal的setting.json
文件进行设置
"profiles": {
"defaults": {
"fontFace": "JetBrainsMono NF",//你需要设置的字体
},
在vscode
中,修改Font-Family
即可完成字体的修改
至此,基本完成了starship
在win10上的安装