Windows 10 ltsc 以上系统安装starshipWindows 10 ltsc 以上系统安装starship一安装Windows Terminal二安装starship安装rust环境三配置starship1. 配置 PowerShell 启动脚本2. 创建配置文件可选3. 字体优化4. 主题设置非必须5. 性能优化建议四设置快捷打开方式方便操作1. 创建注册表文件2. 编辑注册表文件3. 执行文件开始导入注册表4. 验证5. 设置字体解决显示乱码问题验证以及成果展示Windows 10 ltsc 以上系统安装starship[!NOTE]本文着重介绍Windows10 ltsc 以及没有应用商店的系统下安装starship一安装Windows Terminal由于powershell字体显示问题所以需要使用Windows Terminal 更好的兼容starship# 下载地址https://github.com/microsoft/terminal/releases# 将下载后的压缩包解压到自己软件安装目录解压文件如下所示可以自定义自己软件目录二安装starship安装rust环境由于starship是用rust编写的所以安装rust后方便升级和维护版本当然也可以下载.exe安装包安装这里使用cargo安装它下载并安装rust# 官方网站https://rust-lang.org/zh-CN/tools/install/双击打开下载的rustup-init文件并选择1然后等待程序自动完成安装。示例下载并安装 starship# 打开powershell或者cmd窗口执行下面的安装命令cargoinstallstarship--locked三配置starship1. 配置 PowerShell 启动脚本修改powershell权限以管理员身份运行powershell然后执行以下命令Set-ExecutionPolicyRemoteSigned编辑 PowerShell 配置文件$PROFILE若文件不存在则创建它if(!(Test-Path-Path$PROFILE)){New-Item-ItemType File-Path$PROFILE-Force}notepad$PROFILE在打开的文件末尾添加以下内容Invoke-Expression(starship init powershell)验证是否成功打开新的powershell终端查看2. 创建配置文件可选通过以下命令创建该目录New-Item-ItemType Directory-Path$env:USERPROFILE\.config-Force创建配置文件并编辑notepad$env:USERPROFILE\.config\starship.toml执行命令后提示是否创建文件选择是示例配置如下# ~/.config/starship.toml # Use custom format format [┌───────────────────](bold green) [│](bold green)$directory$rust$package [└─](bold green) # Wait 10 milliseconds for starship to check files under the current directory. scan_timeout 60 # Disable the blank line at the start of the prompt add_newline false # Set foo as custom color palette palette foo # Define custom colors [palettes.foo] # Overwrite existing color blue 21 # Define new color mustard #af87003. 字体优化为了更好地显示图标建议安装 Nerd Fonts 字体例如Fira Code Nerd FontCascadia Code Nerd Font安装方式双击安装点击下载字体文件字体文件下载# 字体下载地址 https://www.nerdfonts.com/font-downloads4. 主题设置非必须你可以使用预设主题来快速美化终端。例如starship preset pastel-powerline-o$env:USERPROFILE\.config\starship.toml或starship preset tokyo-night-o$env:USERPROFILE\.config\starship.toml5. 性能优化建议如果你使用的是低配设备可以禁用不常用的模块以提升性能[memory_usage] disabled true [aws] disabled true四设置快捷打开方式方便操作本文介绍将设置按住shift鼠标右键快捷菜单在任意文件夹下只要按住shift 鼠标右键然后选择Windows Terminal 便能快捷打开powershell 命令窗口方便快捷不用来回用cd命令切换路径。1. 创建注册表文件在桌面上按住shift点击鼠标右键在弹出的菜单中选择在此处打开powershell窗口输入如下命令创建并编辑文件notepad aa.reg2. 编辑注册表文件输入以下内容注意文中wt.exe文件路径必须正确你的文件放在哪里就要把路径改成哪里这里作者放在了C盘Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenTerminalHere] Windows Terminal Extended [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenTerminalHere\command] \C:\\terminal-1.25.622.0\\wt.exe\ -p \Windows PowerShell\ -d \%V\ [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenTerminalHere\Icon] C:\\Windows\\System32\\shell32.dll,-167最后保存并关闭记事本。3. 执行文件开始导入注册表回到桌面上双击打开注册表文件aa.reg4. 验证在任意目录下 按住shift点击鼠标右键在弹出的菜单中选择在Windows Terminal5. 设置字体解决显示乱码问题打开Windows Terminal 后点开设置- 配置文件默认值-其他设置外观-字体选择一个刚才安装的字体。验证以及成果展示最后打开Windows Terminal 效果如下通过以上步骤你就可以在 Windows 上成功安装并配置 Starship打造一个美观又实用的终端环境。本文提到的安装包下载地址如下下载