|
| 1 | +--- |
| 2 | +date: 2025-11-03 |
| 3 | +categories: |
| 4 | + - Vibe Coding |
| 5 | + - Setup |
| 6 | +--- |
| 7 | + |
| 8 | +# Mac 终端终极配置指南 |
| 9 | + |
| 10 | +1. 快速的终端体验 -> Ghostty |
| 11 | +2. 让眼睛愉悦的审美 -> catppuccin |
| 12 | +3. 个性化终端显示 -> starship |
| 13 | +4. 终端命令补全及高亮 -> zsh-autosuggestions |
| 14 | + |
| 15 | +{ width="70%" } |
| 16 | + |
| 17 | +<!-- more --> |
| 18 | + |
| 19 | +## 安装 |
| 20 | + |
| 21 | +```shell |
| 22 | +brew install --cask ghostty # 终端 |
| 23 | +brew install starship # 终端自定义 |
| 24 | +brew install font-meslo-lg-nerd-font # 图标字体支持 |
| 25 | +brew install zsh-autosuggestions # 终端命令自动提示及补全 |
| 26 | +brew install zsh-syntax-highlighting # 终端语法高亮 |
| 27 | +``` |
| 28 | + |
| 29 | +追加如下命令到`~/.zshrc`末尾: |
| 30 | + |
| 31 | +```shell |
| 32 | +source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh |
| 33 | +source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh |
| 34 | +eval "$(starship init zsh)" |
| 35 | +``` |
| 36 | + |
| 37 | +## 🍉starship |
| 38 | + |
| 39 | +我的配置主要参照[官方配置说明](https://starship.rs/config/)并结合[catppuccin](https://github.com/catppuccin/starship/blob/main/starship.toml)的审美调教。首先运行如下命令创建配置文件。 |
| 40 | + |
| 41 | +```shell |
| 42 | +mkdir -p ~/.config && touch ~/.config/starship.toml |
| 43 | +``` |
| 44 | + |
| 45 | +具体配置方面 : ) |
| 46 | + |
| 47 | +- 采用mocha配色主题 |
| 48 | +- 取消了命令行前缀变色的逻辑(无效信息) |
| 49 | +- 命令行显示针对超长路径进行优化,只显示最后2层的完整路径,前缀路径只显示第一个字母 |
| 50 | +- 关闭了一些关于username/hostname/package version等的显示 |
| 51 | + |
| 52 | +```toml |
| 53 | +"$schema" = 'https://starship.rs/config-schema.json' |
| 54 | +palette = "catppuccin_mocha" |
| 55 | +add_newline = true |
| 56 | + |
| 57 | +[git_branch] |
| 58 | +style = "bold mauve" |
| 59 | + |
| 60 | +[directory] |
| 61 | +format = "[$path]($style) " |
| 62 | +style = "bold lavender" |
| 63 | + |
| 64 | +# 借鉴 p10k “shortened”:除最后一段外,每段取前 N 个字符 |
| 65 | +fish_style_pwd_dir_length = 1 # 1=首字母,2=前两字母… |
| 66 | +truncation_length = 2 # 最多显示 n 段 |
| 67 | +truncation_symbol = "…/" # 省略号样式 |
| 68 | +truncate_to_repo = true # 进入仓库后从仓库根开始计数 |
| 69 | +home_symbol = "~" # 家目录符号 |
| 70 | + |
| 71 | +[username] |
| 72 | +disabled = true |
| 73 | +[hostname] |
| 74 | +disabled = true |
| 75 | +[time] |
| 76 | +disabled = true |
| 77 | +[package] |
| 78 | +disabled = true |
| 79 | +[nodejs] |
| 80 | +disabled = true |
| 81 | +[python] |
| 82 | +disabled = true |
| 83 | +[gcloud] |
| 84 | +disabled = true |
| 85 | + |
| 86 | +[palettes.catppuccin_mocha] |
| 87 | +rosewater = "#f5e0dc" |
| 88 | +flamingo = "#f2cdcd" |
| 89 | +pink = "#f5c2e7" |
| 90 | +mauve = "#cba6f7" |
| 91 | +red = "#f38ba8" |
| 92 | +maroon = "#eba0ac" |
| 93 | +peach = "#fab387" |
| 94 | +yellow = "#f9e2af" |
| 95 | +green = "#a6e3a1" |
| 96 | +teal = "#94e2d5" |
| 97 | +sky = "#89dceb" |
| 98 | +sapphire = "#74c7ec" |
| 99 | +blue = "#89b4fa" |
| 100 | +lavender = "#b4befe" |
| 101 | +text = "#cdd6f4" |
| 102 | +subtext1 = "#bac2de" |
| 103 | +subtext0 = "#a6adc8" |
| 104 | +overlay2 = "#9399b2" |
| 105 | +overlay1 = "#7f849c" |
| 106 | +overlay0 = "#6c7086" |
| 107 | +surface2 = "#585b70" |
| 108 | +surface1 = "#45475a" |
| 109 | +surface0 = "#313244" |
| 110 | +base = "#1e1e2e" |
| 111 | +mantle = "#181825" |
| 112 | +crust = "#11111b" |
| 113 | +``` |
| 114 | + |
| 115 | +## Ghostty |
| 116 | + |
| 117 | +创建配置文件夹及配置文件。 |
| 118 | + |
| 119 | +```shell |
| 120 | +mkdir -p ~/.config/ghostty/themes && touch ~/.config/ghostty/config |
| 121 | +``` |
| 122 | + |
| 123 | +下载 [catppuccin主题文件](https://github.com/catppuccin/ghostty/tree/main/themes)到 `~/.config/ghostty/themes` 路径中,配置`~/.config/ghostty/config` 文件。 |
| 124 | + |
| 125 | +``` |
| 126 | +theme = catppuccin-mocha.conf |
| 127 | +
|
| 128 | +font-family = MesloLGS Nerd Font Mono |
| 129 | +font-size = 24 |
| 130 | +window-width = 90 |
| 131 | +window-height = 30 |
| 132 | +background-opacity = 0.99 |
| 133 | +
|
| 134 | +keybind = shift+enter=text:\n |
| 135 | +keybind = global:cmd+backslash=toggle_visibility |
| 136 | +# keybind = cmd+shift+comma=reload_config |
| 137 | +
|
| 138 | +# cursor settings |
| 139 | +cursor-style = block |
| 140 | +cursor-style-blink = false |
| 141 | +cursor-color = #40a02b |
| 142 | +cursor-text = #000000 |
| 143 | +shell-integration-features = no-cursor |
| 144 | +``` |
| 145 | + |
| 146 | +到此配置结束,启动你的ghostty看看效果吧! |
| 147 | + |
| 148 | +{ width="50%" } |
| 149 | +## Tips |
| 150 | + |
| 151 | +- **命令部分补全**,使用 `->` 可以完整接受命令补全结果,使用`option + ->`可移动光标进行部分补全 |
| 152 | + |
| 153 | +- **Ghostty远程连接按键错位**,ghostty在ssh连接remote server可能会出现按键错位,将 `user@server` 替换后在执行: |
| 154 | +```shell |
| 155 | +infocmp -x xterm-ghostty | ssh user@server -- 'tic -x -o ~/.terminfo -' |
| 156 | +``` |
| 157 | +- Ghostty窗口重命名,这个在使用Git worktree配合 Claude Code等Coding Agent Cli时特别有用,首先通过`command + shift + p`招出命令搜索界面,输入`title`就可以看到`change title`的命令了,然后重命名即可! |
0 commit comments