从p10k转向Starship
2023-3-25
·
hexer

本文又名“发现了一个终端神器Starship”,好像软文的味还不够,那就换成“震惊,新一代终端主题竟然是这样的”

p10k虽然还不错,但是总是感觉不够舒服,有时候可能是有点卡,有时候可能总是觉得不太顺

想着有兴趣就折腾一下,在github逛来逛去,发现了Starship

首先需要将p10k卸掉,我是zsh里安装的zim,用zim安装的p10k,查看一下文档,zim卸载掉p10k,直接zimfw uninstall即可

安装字体

Starship安装文档中,说明了需要安装安装并在终端启用 Nerd Font 字体,我使用的是konsole所以以下流程仅适用于konsole

需要将字体下载至~/.local/share/fonts

mkdir -p ~/.local/share/fonts
cd ~/.local/share/fonts && curl -fLo "Droid Sans Mono for Powerline Nerd Font Complete.otf" https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DroidSansMono/complete/Droid%20Sans%20Mono%20Nerd%20Font%20Complete.otf

然后输入fc-cache -f -v刷新字体缓存,然后关闭konsole再开启,打开Settings → Edit Current Profile → Appearance,点击Select Font并选择字体

安装starship

我的操作系统是ArchLinux,所以sudo pacman -S starship

将下面这行添加到~/.zshrc

eval "$(starship init zsh)"

就安装完成了

我的配置

贴一下我的配置吧,根据官方的其中一个预设改的,配色参考dracula

[aws]
format = '\[[$symbol($profile)(\($region\))(\[$duration\])]($style)\]'

[bun]
format = '\[[$symbol($version)]($style)\]'

[c]
format = '\[[$symbol($version(-$name))]($style)\]'

[cmake]
format = '\[[$symbol($version)]($style)\]'

[cmd_duration]
style = '#f1fa8c'
format = '\[[󱑁 $duration]($style)\]'

[cobol]
format = '\[[$symbol($version)]($style)\]'

[conda]
symbol = ''
format = '\[[$symbol$environment]($style)\]'

[crystal]
format = '\[[$symbol($version)]($style)\]'

[daml]
format = '\[[$symbol($version)]($style)\]'

[dart]
format = '\[[$symbol($version)]($style)\]'

[deno]
format = '\[[$symbol($version)]($style)\]'

[docker_context]
format = '\[[$symbol$context]($style)\]'

[dotnet]
format = '\[[$symbol($version)(🎯 $tfm)]($style)\]'

[elixir]
format = '\[[$symbol($version \(OTP $otp_version\))]($style)\]'

[elm]
format = '\[[$symbol($version)]($style)\]'

[erlang]
format = '\[[$symbol($version)]($style)\]'

[fennel]
format = '\[[$symbol($version)]($style)\]'

[fossil_branch]
format = '\[[$symbol$branch]($style)\]'

[gcloud]
format = '\[[$symbol$account(@$domain)(\($region\))]($style)\]'

[git_branch]
style = '#bd93f9'
format = '\[[$symbol$branch]($style)\]'

[git_status]
style = '#ff5555'
format = '([\[$all_status$ahead_behind\]]($style))'

[golang]
format = '\[[$symbol($version)]($style)\]'

[gradle]
format = '\[[$symbol($version)]($style)\]'

[guix_shell]
format = '\[[$symbol]($style)\]'

[haskell]
format = '\[[$symbol($version)]($style)\]'

[haxe]
format = '\[[$symbol($version)]($style)\]'

[helm]
format = '\[[$symbol($version)]($style)\]'

[hg_branch]
format = '\[[$symbol$branch]($style)\]'

[java]
format = '\[[$symbol($version)]($style)\]'

[julia]
format = '\[[$symbol($version)]($style)\]'

[kotlin]
format = '\[[$symbol($version)]($style)\]'

[kubernetes]
format = '\[[$symbol$context( \($namespace\))]($style)\]'

[lua]
format = '\[[$symbol($version)]($style)\]'

[memory_usage]
format = '\[$symbol[$ram( | $swap)]($style)\]'

[meson]
format = '\[[$symbol$project]($style)\]'

[nim]
format = '\[[$symbol($version)]($style)\]'

[nix_shell]
format = '\[[$symbol$state( \($name\))]($style)\]'

[nodejs]
format = '\[[$symbol($version)]($style)\]'

[ocaml]
format = '\[[$symbol($version)(\($switch_indicator$switch_name\))]($style)\]'

[opa]
format = '\[[$symbol($version)]($style)\]'

[openstack]
format = '\[[$symbol$cloud(\($project\))]($style)\]'

[os]
format = '\[[󰣇 ]($style)\]'

[package]
format = '\[[$symbol$version]($style)\]'

[perl]
format = '\[[$symbol($version)]($style)\]'

[php]
format = '\[[$symbol($version)]($style)\]'

[pijul_channel]
format = '\[[$symbol$channel]($style)\]'

[pulumi]
format = '\[[$symbol$stack]($style)\]'

[purescript]
format = '\[[$symbol($version)]($style)\]'

[python]
format = '\[[${symbol}${pyenv_prefix}(${version})(\($virtualenv\))]($style)\]'

[raku]
format = '\[[$symbol($version-$vm_version)]($style)\]'

[red]
format = '\[[$symbol($version)]($style)\]'

[ruby]
format = '\[[$symbol($version)]($style)\]'

[rust]
format = '\[[$symbol($version)]($style)\]'

[scala]
format = '\[[$symbol($version)]($style)\]'

[spack]
format = '\[[$symbol$environment]($style)\]'

[sudo]
format = '\[[as $symbol]\]'

[swift]
format = '\[[$symbol($version)]($style)\]'

[terraform]
format = '\[[$symbol$workspace]($style)\]'

[time]
format = '\[[$time]($style)\]'

[username]
format = '\[[$user]($style)\]'

[vagrant]
format = '\[[$symbol($version)]($style)\]'

[vlang]
format = '\[[$symbol($version)]($style)\]'

[zig]
format = '\[[$symbol($version)]($style)\]'

[directory]
style = "#ffb86c"
format = "[ $path]($style)"
truncation_length = 5
truncation_symbol = "…/"

# 替换
[directory.substitutions]
"Documents" = " "
"Downloads" = " "
"Music" = " "
"Pictures" = " "
".ssh" = ""
".config" = ""

[character]
success_symbol = '[](bold green)'
error_symbol = '[](bold red)'