starship是什么
轻量、迅速、客制化的高颜值终端!
快: 很快 —— 真的真的非常快! 🚀
客制化: 可定制各种各样的提示符。
通用: 适用于任何 Shell、任何操作系统。
智能: 一目了然地显示相关信息。
功能丰富: 支持所有你喜欢的工具。
易用: 安装快速 —— 几分钟就可上手。
官网:https://starship.rs/zh-CN/
Github:https://github.com/starship/starship
配置powershell
- 下载后安装
Windows
在 发布页 下载 MSI 包来安装最新版。
使用下列软件包管理器安装Starship:
软件包来源 指令
crates.io cargo install starship --locked
Chocolatey choco install starship
conda-forge conda install -c conda-forge starship
Scoop scoop install starship
winget winget install --id Starship.Starship
- 配置
查看配置文件的路径
PS C:\Users\johnny> $PROFILE
C:\Users\johnny\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
如果提示找不到文件,可以先创建文件,直接复制下面命令
# 获取配置文件目录路径
$profileDir = Split-Path -Parent $PROFILE
# 检查并创建配置文件目录
if (-not (Test-Path -Path $profileDir)) {
New-Item -ItemType Directory -Path $profileDir
}
# 创建 PowerShell 配置文件
New-Item -ItemType File -Path $PROFILE -Force
# 打开 PowerShell 配置文件
notepad $PROFILE
将以下内容添加到您 PowerShell 配置文件的末尾(通过运行 来获取配置文件的路径)
Invoke-Expression (&starship init powershell)
- 重新打开powershell
主题美化
starship preset pastel-powerline -o "$env:USERPROFILE\.config\starship.toml"
starship preset gruvbox-rainbow -o "$env:USERPROFILE\.config\starship.toml"
starship preset tokyo-night -o "$env:USERPROFILE\.config\starship.toml"
starship preset pastel-powerline -o "$env:USERPROFILE\.config\starship.toml"
手动修改配置,starship.toml
,来自这里
# ~/.config/starship.toml
format = """
$time \
$username\
$directory \
$character\
"""
add_newline = false
[battery]
full_symbol = "🔋"
charging_symbol = "🔌"
discharging_symbol = "⚡"
[[battery.display]]
threshold = 30
style = "bold red"
[character]
error_symbol = "[❌](bold red)"
#success_symbol = "[⚡](bold green)"
#success_symbol = "[✨](bold green)"
success_symbol = "[💖](bold green)"
[cmd_duration]
min_time = 0 # Show command duration over 10,000 milliseconds (=10 sec)
format = " took [$duration]($style)"
[directory]
truncation_length = 5
format = "[$path]($style)[$lock_symbol]($lock_style)"
[git_branch]
format = " [$symbol$branch]($style) "
symbol = "🍣 "
style = "bold yellow"
[git_commit]
commit_hash_length = 8
style = "bold white"
[git_state]
format = '[\($state( $progress_current of $progress_total)\)]($style) '
[git_status]
conflicted = "⚔️ "
ahead = "🏎️ 💨 ×${count}"
behind = "🐢 ×${count}"
diverged = "🔱 🏎️ 💨 ×${ahead_count} 🐢 ×${behind_count}"
untracked = "🛤️ ×${count}"
stashed = "📦 "
modified = "📝 ×${count}"
staged = "🗃️ ×${count}"
renamed = "📛 ×${count}"
deleted = "🗑️ ×${count}"
style = "bright-white"
format = "$all_status$ahead_behind"
[hostname]
ssh_only = false
format = "<[$hostname]($style)>"
trim_at = "-"
style = "bold dimmed white"
disabled = true
[julia]
format = "[$symbol$version]($style) "
symbol = "ஃ "
style = "bold green"
[memory_usage]
format = "$symbol[${ram}( | ${swap})]($style) "
threshold = 70
style = "bold dimmed white"
disabled = false
[username]
style_user = "green"
show_always = true
format = "[$user]($style) "
[time]
disabled = false
time_format = "%R" # Hour:Minute Format
format = '[$time]($style)'
style = "bold white"
参考:
https://starship.rs/zh-CN/guide/
https://starship.rs/zh-CN/presets/ 官方
https://juejin.cn/post/7403547816914927642
https://blog.youkuaiyun.com/m0_70586433/article/details/146359521
https://www.gerenbiji.com/blog/2024%E5%B9%B4/Starship%20%E7%BE%8E%E5%8C%96%E7%BB%88%E7%AB%AF/