Starship 是什么

Starship: cross-shell prompt

Starship 是轻量的、高性能、高颜值、跨平台的终端提示美化软件。

安装

前置条件

终端支持 Nerd Fonts

如果你用的是 Mac - Homebrew 的话,进行如下操作:

brew tap homebrew/cask-fonts
brew install font-hack-nerd-font

安装 starship

  1. 下载安装
  • 使用 Homebrew
brew install starship
  • 使用 shell 一键安装脚本
curl -sS https://starship.rs/install.sh | sh
  1. 添加初始化配置
  • zsh 添加内容到 .zshrc 文件中:
eval "$(starship init zsh)"

配置

# 通用方式
mkdir -p ~/.config && touch ~/.config/starship.toml
 
# 我的方式
mkdir -p ~/dotfiles/starship && touch ~/.config/starship.toml
ln -sf $HOME/dotfiles/starship/starship.toml $HOME/.config/starship.toml

添加如下内容到 starship.tomldotfiles/starship/starship.toml

# Get editor completions based on the config schema
"$schema" = 'https://starship.rs/config-schema.json'
palette = "catppuccin_mocha"
 
# Inserts a blank line between shell prompts
add_newline = true
 
[aws]
symbol = "  "
 
[buf]
symbol = " "
 
[c]
symbol = " "
 
# Replace the '❯' symbol in the prompt with '➜'
[character] # The name of the module we are configuring is 'character'
#success_symbol = '[➜](bold green)' # The 'success_symbol' segment is being set to '➜' with the color 'bold green'
success_symbol = "[[♥](green) ❯](maroon)"
error_symbol = "[❯](red)"
vimcmd_symbol = "[❮](green)"
 
[conda]
symbol = " "
 
[crystal]
symbol = " "
 
[dart]
symbol = " "
 
[directory]
read_only = " 󰌾"
truncation_length = 10
truncate_to_repo = false
# Catppuccin 'lavender'
style = "bold lavender"
 
[docker_context]
symbol = " "
 
[elixir]
symbol = " "
 
[elm]
symbol = " "
 
[fennel]
symbol = " "
 
[fossil_branch]
symbol = " "
 
[git_branch]
symbol = " "
 
[git_commit]
commit_hash_length = 6
tag_symbol = '🔖 '
 
[golang]
symbol = " "
 
[guix_shell]
symbol = " "
 
[haskell]
symbol = " "
 
[haxe]
symbol = " "
 
[hg_branch]
symbol = " "
 
[hostname]
ssh_symbol = " "
 
[java]
symbol = " "
 
[julia]
symbol = " "
 
[kotlin]
symbol = " "
 
[kubernetes]
disabled = false
 
[lua]
symbol = " "
 
[memory_usage]
symbol = "󰍛 "
 
[meson]
symbol = "󰔷 "
 
[nim]
symbol = "󰆥 "
 
[nix_shell]
symbol = " "
 
[nodejs]
symbol = " "
disabled = true
 
[ocaml]
symbol = " "
 
[os.symbols]
Alpaquita = " "
Alpine = " "
AlmaLinux = " "
Amazon = " "
Android = " "
Arch = " "
Artix = " "
CentOS = " "
Debian = " "
DragonFly = " "
Emscripten = " "
EndeavourOS = " "
Fedora = " "
FreeBSD = " "
Garuda = "󰛓 "
Gentoo = " "
HardenedBSD = "󰞌 "
Illumos = "󰈸 "
Kali = " "
Linux = " "
Mabox = " "
Macos = " "
Manjaro = " "
Mariner = " "
MidnightBSD = " "
Mint = " "
NetBSD = " "
NixOS = " "
OpenBSD = "󰈺 "
openSUSE = " "
OracleLinux = "󰌷 "
Pop = " "
Raspbian = " "
Redhat = " "
RedHatEnterprise = " "
RockyLinux = " "
Redox = "󰀘 "
Solus = "󰠳 "
SUSE = " "
Ubuntu = " "
Unknown = " "
Void = " "
Windows = "󰍲 "
 
# Disable the package module, hiding it from the prompt completely
[package]
symbol = "󰏗 "
disabled = true
 
[perl]
symbol = " "
 
[php]
symbol = " "
 
[pijul_channel]
symbol = " "
 
[python]
symbol = " "
 
[rlang]
symbol = "󰟔 "
 
[ruby]
symbol = " "
 
[rust]
symbol = " "
 
[scala]
symbol = " "
 
[swift]
symbol = " "
 
[zig]
symbol = " "
 
[palettes.catppuccin_mocha]
rosewater = "#f5e0dc"
flamingo = "#f2cdcd"
pink = "#f5c2e7"
mauve = "#cba6f7"
red = "#f38ba8"
maroon = "#eba0ac"
peach = "#fab387"
yellow = "#f9e2af"
green = "#a6e3a1"
teal = "#94e2d5"
sky = "#89dceb"
sapphire = "#74c7ec"
blue = "#89b4fa"
lavender = "#b4befe"
text = "#cdd6f4"
subtext1 = "#bac2de"
subtext0 = "#a6adc8"
overlay2 = "#9399b2"
overlay1 = "#7f849c"
overlay0 = "#6c7086"
surface2 = "#585b70"
surface1 = "#45475a"
surface0 = "#313244"
base = "#1e1e2e"
mantle = "#181825"
crust = "#11111b"