iTerm 里一直是用 powerlevel10k 来自定义主题,最近网友推荐了一个新的 Starship,周末刚好折腾一下。
已有 zsh 和 Oh My Zsh 的环境,这些就不在这里赘述,powerlevel10k 卸载 对照网页操作。
- autojump
- zsh-syntax-highlighting
- zsh-autosuggestions
- zsh-osx-autoproxy
Starship 安装
- 使用 Homebrew 安装,终端窗口运行
brew install starship
- Finder 里打开~/.zshrc 文件,在配置文件的最后添加一行:
eval \"$(starship init zsh)\"
- 创建配置文件 ~/.config/starship.toml 以供 Starship 使用:
mkdir -p ~/.config && touch ~/.config/starship.toml
- 编辑 ~/.config/starship.toml 文件,Copy 默认配置到文件中保存。
Starship 配置
熟悉后,可以根据个人使用习惯对配置做一些调整,例如:
- 启用右侧提示,在右侧增加了时间显示
- 提示符号换成自己想要的
附上完整的配置文件:
# 设置配置范例,开启编辑器的自动补全
\"$schema\" = \'https://starship.rs/config-schema.json\'
# 在命令之间插入空行
add_newline = false
# ~/.config/starship.toml
# A minimal left prompt
format = \"\"\"$character\"\"\"
# move the rest of the prompt to the right
right_format = \"\"\"$all\"\"\"
[line_break]
disabled = true
# 将提示符的“❯”替换为“➜”
[character] # “character”是我们正在配置的组件
success_symbol = \"[❯](bold green)\" # 设置“success_symbol” 字段为绿色加粗的“➜”
# 禁用 package 组件,完全隐藏它的提示符
[package]
disabled = true
[localip]
ssh_only = true
format = \"@[$localipv4](bold red) \"
disabled = false
[time]
disabled = false
time_format = \"%R\" # Hour:Minute Format
style = \"bg:none\"
format = \'[[♥ $time ](bg:none)]($style)\'
字体是安装了一个自己 Patch 的 SF Mono,具体方式可以参考:把 SF Mono 字体 Patch 上 Nerd Font,这篇文章操作。
懒人直接下载安装(仅能个人使用):SFMono-Medium-Nerd-Font-Complete-Mono.otf
用 exa 替代 ls 命令
安装 Exa: 更棒的 ls 指令 替代 ls 命令,输出更好看的文件列表,exa 还支持 tree 目录树输出。 brew install exa
完成安装后,记得去 .zshrc 文件中修改添加一下别名,方便平时使用。
alias ls=\'exa\'
alias la=\'exa -a\'
alias ll=\'exa -lh\'
#alias la=\'exa -lah\'
alias lr=\'exa -lR\'