Starshipのインストール方法:macOS/Linuxでstarship.tomlを設定しzsh/fishに組み込む
Starshipを入れ、starship.tomlを設定し、zsh/fishでクロスシェルプロンプトを有効化。
端末でGit ブランチ・パス・コマンド時間を一度に見たいとき、デフォルト PS1 は情報不足になりがちです。Starship は Rust 製のクロスシェルプロンプトで、zsh か fish に1行追加し、設定は ~/.config/starship.toml に集約します。macOS/Linux の公式インストールと初回設定を hereink 読者向けにまとめます。
検索語はmacOS/Linux で Starship を入れ zsh/fish を設定する方法。バイナリ導入、init 行、starship.toml 編集まで完了させます。
Starship が解くこと
手書き PS1 より保守しやすい
モジュール(directory、git_branch、cmd_duration)を TOML で管理。テーマ変更にシェルスクリプト不要。
シェル間で見た目を統一
macOS の zsh、リモートの bash、ローカルの fish でも同じ starship.toml で一貫したプロンプト。
公式:
starship.rs。starship --versionで確認。
macOS/Linux にインストール
- 1macOS(Homebrew)
brew install starship。which starshipとstarship --version。 - 2Linux パッケージ
Debian/Ubuntu:公式リポジトリ追加後
apt install starship。Fedora:dnf install starship。Arch:pacman -S starship。 - 3インストール脚本
curl -sS https://starship.rs/install.sh | sh。~/.local/binを PATH に。 - 4cargo(任意)
cargo install starship --locked。
zsh / fish に組み込む
# zsh — ~/.zshrc に追加
eval "$(starship init zsh)"
# fish — ~/.config/fish/config.fish
starship init fish | source
# bash — ~/.bashrc
eval "$(starship init bash)"保存後新しい端末を開くか source。変わらなければ PATH を確認。
~/.config/starship.toml を編集
| モジュール | 役割 | 例 |
|---|---|---|
[directory] | 現在パス | truncation_length = 3 |
[git_branch] | Git ブランチ | symbol = " " |
[cmd_duration] | 遅いコマンドの時間 | min_time = 500 |
format | モジュール順 | format = "$directory$git_branch$character" |
- 向く
- zsh/fish で日常開発、Git リポジトリを行き来する人。
- 向かない
- レガシー PS1 必須の踏み台;Nerd Font 不可の端末。
starship が見つからない?
PATH にバイナリがない。Homebrew の shellenv または ~/.local/bin を export。
Oh My Zsh と競合?
ZSH_THEME を無効化し starship init のみ残す。
設定が反映されない?
~/.config/starship.toml を編集しているか確認。starship config で編集。
端末が整ったら図で揃える
サービス境界は一枚の図が向く。スペースの作り方。