Graphite実践ガイド - Rust製2Dグラフィックエディタ
Rust言語で開発されたオープンソース2DグラフィックエディタGraphiteの使い方を徹底解説。ノードベースの編集、WebAssembly対応、プロシージャル生成など、革新的な機能を詳しく紹介します。
Rust製の高速プロンプト「Starship」の設定方法を徹底解説。Git情報、言語バージョン、実行時間などを美しく表示するカスタマイズテクニックを紹介します。
ターミナルのプロンプトは、開発者が最も頻繁に目にするインターフェースの 1 つです。 しかし、多くの開発者はデフォルトの味気ないプロンプトのまま使い続けています。
Starshipは、この状況を劇的に変える次世代プロンプトです。 Rust 製で超高速、クロスシェル対応、そして美しいデザインが特徴です。
従来のシェルプロンプトやテーマには、いくつかの課題があります:
プロンプト/テーマ | 速度 | カスタマイズ性 | クロスシェル | メンテナンス |
---|---|---|---|---|
デフォルトプロンプト | ⭐⭐⭐⭐⭐ | ⭐ | ❌ | ⭐⭐⭐⭐⭐ |
Oh My Zsh | ⭐⭐ | ⭐⭐⭐⭐ | ❌ | ⭐⭐⭐ |
Powerlevel10k | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ❌ | ⭐⭐⭐⭐ |
Starship | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ✅ | ⭐⭐⭐⭐⭐ |
# Homebrewを使用
brew install starship
# または、インストールスクリプトを使用
curl -sS https://starship.rs/install.sh | sh
# インストールスクリプトを使用
curl -sS https://starship.rs/install.sh | sh
# Arch Linux(AUR)
yay -S starship
# Ubuntu/Debian(snap)
sudo snap install starship
# Scoopを使用
scoop install starship
# またはChocolateyを使用
choco install starship
# またはWingetを使用
winget install --id Starship.Starship
インストール後、各シェルの設定ファイルに以下を追加します:
# ~/.bashrcの最後に追加
eval "$(starship init bash)"
# ~/.zshrcの最後に追加
eval "$(starship init zsh)"
# ~/.config/fish/config.fishに追加
starship init fish | source
# $PROFILEに追加
Invoke-Expression (&starship init powershell)
Starship の設定は ~/.config/starship.toml
に記述します。
TOML フォーマットを使用した直感的な設定が可能です。
~/.config/starship.toml
%USERPROFILE%\.config\starship.toml
# プロンプト全体のフォーマット
format = """
[](bold green)$username\
[](bg:#DA627D fg:#9A348E)\
$directory\
[](fg:#DA627D bg:#FCA17D)\
$git_branch\
$git_status\
[](fg:#FCA17D bg:#86BBD8)\
$nodejs\
$rust\
$golang\
$php\
[](fg:#86BBD8 bg:#06969A)\
$docker_context\
[](fg:#06969A bg:#33658A)\
$time\
[ ](fg:#33658A)\
"""
# コマンド実行時間の表示
[cmd_duration]
min_time = 500
format = "⏱ [$duration]($style) "
Starship は多数のモジュールを提供しており、それぞれが特定の情報を表示します。
[git_branch]
symbol = " "
style = "bold purple"
format = "[$symbol$branch]($style) "
[git_status]
style = "bold red"
format = '([\[$all_status$ahead_behind\]]($style) )'
conflicted = "⚔️ "
ahead = "⬆️ ×${count}"
behind = "⬇️ ×${count}"
diverged = "🔱 ⬆️ ×${ahead_count} ⬇️ ×${behind_count}"
untracked = "🤷 ×${count}"
stashed = "📦 "
modified = "📝 ×${count}"
staged = "➕ ×${count}"
renamed = "🔤 ×${count}"
deleted = "🗑️ ×${count}"
[nodejs]
format = "via [$symbol($version )]($style)"
[python]
format = "via [$symbol($version )]($style)"
[rust]
format = "via [$symbol($version )]($style)"
[nodejs]
symbol = " "
style = "bold green"
format = "[$symbol($version )]($style)"
detect_extensions = ["js", "mjs", "cjs", "ts", "mts", "cts"]
[python]
symbol = " "
style = "bold yellow"
format = "[$symbol($version )]($style)"
python_binary = ["python3", "python"]
[rust]
symbol = " "
style = "bold red"
format = "[$symbol($version )]($style)"
[nodejs]
format = "via [$symbol($version )]($style)"
[python]
format = "via [$symbol($version )]($style)"
[rust]
format = "via [$symbol($version )]($style)"
[nodejs]
symbol = " "
style = "bold green"
format = "[$symbol($version )]($style)"
detect_extensions = ["js", "mjs", "cjs", "ts", "mts", "cts"]
[python]
symbol = " "
style = "bold yellow"
format = "[$symbol($version )]($style)"
python_binary = ["python3", "python"]
[rust]
symbol = " "
style = "bold red"
format = "[$symbol($version )]($style)"
[directory]
style = "bold cyan"
format = "[$path]($style)[$read_only]($read_only_style) "
truncation_length = 3
truncation_symbol = "…/"
home_symbol = " ~"
read_only = " "
read_only_style = "red"
[directory.substitutions]
"Documents" = " "
"Downloads" = " "
"Music" = " "
"Pictures" = " "
"Developer" = " "
実際の開発現場では、プロジェクトの種類に応じて異なる情報を表示したいケースがあります。 以下は、様々な開発環境に最適化された設定例です。
# フルスタック開発者向け設定
format = """
$username\
$hostname\
$directory\
$git_branch\
$git_status\
$nodejs\
$python\
$ruby\
$rust\
$golang\
$php\
$docker_context\
$kubernetes\
$terraform\
$aws\
$gcloud\
$azure\
$cmd_duration\
$line_break\
$character
"""
# Node.js詳細設定
[nodejs]
symbol = " "
style = "bold green"
format = "[$symbol($version )]($style)"
version_format = "v${major}.${minor}"
detect_extensions = ["js", "mjs", "cjs", "ts", "mts", "cts"]
detect_files = ["package.json", ".node-version", ".nvmrc"]
detect_folders = ["node_modules"]
# パッケージ情報
[package]
symbol = "📦 "
style = "bold 208"
format = "[$symbol$version]($style) "
version_format = "v${raw}"
# Docker設定
[docker_context]
symbol = " "
style = "bold blue"
format = "[$symbol$context]($style) "
only_with_files = true
detect_files = ["docker-compose.yml", "docker-compose.yaml", "Dockerfile"]
# データベース接続インジケーター(カスタム)
[custom.database]
command = "echo $DATABASE_URL | sed 's/.*@//' | sed 's/:.*//'"
when = "test -n \"$DATABASE_URL\""
symbol = " "
style = "bold yellow"
format = "[$symbol($output )]($style)"
description = "現在接続中のデータベース"
# データサイエンティスト向け設定
format = """
$username\
$hostname\
$directory\
$git_branch\
$git_status\
$python\
$conda\
$jupyter\
$custom.gpu\
$memory_usage\
$jobs\
$cmd_duration\
$line_break\
$character
"""
# Python詳細設定
[python]
symbol = " "
style = "bold yellow"
format = "[$symbol$version( \\($virtualenv\\))]($style) "
python_binary = ["python3", "python"]
detect_extensions = ["py", "ipynb"]
detect_files = ["requirements.txt", "setup.py", "pyproject.toml", "Pipfile"]
# Conda環境
[conda]
symbol = " "
style = "bold green"
format = "[$symbol$environment]($style) "
ignore_base = false
# メモリ使用量
[memory_usage]
symbol = " "
style = "bold dimmed white"
format = "[$symbol$ram_pct]($style) "
threshold = 75
disabled = false
# GPU使用状況(カスタム)
[custom.gpu]
command = "nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits | awk '{print $1\"%\"}'"
when = "which nvidia-smi"
symbol = " "
style = "bold green"
format = "[$symbol($output )]($style)"
description = "GPU使用率"
# Jupyter環境インジケーター(カスタム)
[custom.jupyter]
command = "jupyter --version 2>/dev/null | head -n1 | awk '{print $2}'"
when = "test -n \"$JUPYTER_RUNTIME_DIR\""
symbol = " "
style = "bold orange"
format = "[$symbol($output )]($style)"
description = "Jupyter環境"
# DevOpsエンジニア向け設定
format = """
$username\
$hostname\
$kubernetes\
$directory\
$git_branch\
$git_status\
$terraform\
$docker_context\
$aws\
$gcloud\
$azure\
$custom.helm\
$custom.ansible\
$golang\
$python\
$cmd_duration\
$line_break\
$character
"""
# Kubernetes詳細設定
[kubernetes]
symbol = "☸ "
style = "bold blue"
format = "[$symbol$context( \\($namespace\\))]($style) "
disabled = false
[kubernetes.context_aliases]
"dev-k8s" = "dev"
"staging-k8s" = "staging"
"production-k8s" = "prod"
# Terraform設定
[terraform]
symbol = " "
style = "bold purple"
format = "[$symbol$workspace]($style) "
detect_extensions = ["tf", "tfplan", "tfstate"]
detect_files = ["terraform.tfvars", ".terraform.lock.hcl"]
# AWS設定
[aws]
symbol = " "
style = "bold orange"
format = "[$symbol($profile )(\\($region\\) )]($style)"
[aws.region_aliases]
ap-northeast-1 = "tokyo"
us-east-1 = "virginia"
us-west-2 = "oregon"
# Helm状態(カスタム)
[custom.helm]
command = "helm version --short | awk '{print $1}' | sed 's/v//'"
when = "test -f Chart.yaml"
symbol = "⎈ "
style = "bold white"
format = "[$symbol($output )]($style)"
description = "Helmバージョン"
# Ansible状態(カスタム)
[custom.ansible]
command = "ansible --version | head -n1 | awk '{print $2}'"
when = "test -f ansible.cfg || test -f playbook.yml"
symbol = " "
style = "bold red"
format = "[$symbol($output )]($style)"
description = "Ansibleバージョン"
# モバイル開発者向け設定
format = """
$username\
$hostname\
$directory\
$git_branch\
$git_status\
$swift\
$kotlin\
$java\
$dart\
$custom.flutter\
$custom.xcode\
$nodejs\
$ruby\
$cmd_duration\
$line_break\
$character
"""
# Swift設定
[swift]
symbol = " "
style = "bold orange"
format = "[$symbol($version )]($style)"
detect_extensions = ["swift"]
detect_files = ["Package.swift"]
# Kotlin設定
[kotlin]
symbol = " "
style = "bold purple"
format = "[$symbol($version )]($style)"
detect_extensions = ["kt", "kts"]
detect_files = ["build.gradle.kts"]
# Dart/Flutter設定
[dart]
symbol = " "
style = "bold blue"
format = "[$symbol($version )]($style)"
detect_extensions = ["dart"]
detect_files = ["pubspec.yaml", "pubspec.yml"]
# Flutter環境(カスタム)
[custom.flutter]
command = "flutter --version | head -n1 | awk '{print $2}'"
when = "test -f pubspec.yaml && grep -q flutter pubspec.yaml"
symbol = " "
style = "bold cyan"
format = "[$symbol($output )]($style)"
description = "Flutterバージョン"
# Xcode環境(カスタム)
[custom.xcode]
command = "xcodebuild -version | head -n1 | awk '{print $2}'"
when = "test -f *.xcodeproj || test -f *.xcworkspace"
symbol = " "
style = "bold white"
format = "[$symbol($output )]($style)"
description = "Xcodeバージョン"
# CocoaPods(カスタム)
[custom.cocoapods]
command = "pod --version"
when = "test -f Podfile"
symbol = " "
style = "bold red"
format = "[$symbol($output )]($style)"
description = "CocoaPodsバージョン"
# 時間帯によって異なる絵文字を表示
[custom.greeting]
command = """
HOUR=$(date +%H)
if [ $HOUR -lt 6 ]; then echo "🌙"
elif [ $HOUR -lt 12 ]; then echo "☀️"
elif [ $HOUR -lt 18 ]; then echo "🌤"
else echo "🌙"
fi
"""
when = "true"
style = "bold yellow"
format = "[$output ]($style)"
description = "時間帯別の挨拶"
# 作業時間トラッカー(カスタム)
[custom.work_timer]
command = """
if [ -f ~/.work_start ]; then
START=$(cat ~/.work_start)
NOW=$(date +%s)
DIFF=$((NOW - START))
HOURS=$((DIFF / 3600))
MINUTES=$(((DIFF % 3600) / 60))
echo "${HOURS}h ${MINUTES}m"
fi
"""
when = "test -f ~/.work_start"
symbol = "⏱ "
style = "bold red"
format = "[$symbol($output )]($style)"
description = "作業時間"
独自の情報を表示したい場合は、カスタムモジュールを作成できます。
[custom.docker]
command = "docker ps --format '{{.Names}}' | wc -l"
when = "docker info"
symbol = " "
style = "bold blue"
format = "[$symbol($output )]($style)"
description = "稼働中のDockerコンテナ数"
[custom.vpn]
command = "echo VPN"
when = "test -f /var/run/vpn.pid"
symbol = "🔒 "
style = "bold green"
format = "[$symbol$output]($style) "
description = "VPN接続状態"
Starship を最大限活用するには、Nerd Fonts のインストールが推奨されます。
公式サイトから好みのフォントを選択
OSに応じた方法でインストール
インストールしたフォントを選択
アイコンが正しく表示されることを確認
# Catppuccin Mocha テーマ
[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"
palette = "catppuccin_mocha"
# プロジェクトタイプに応じた動的表示
[custom.project_type]
command = """
if [ -f package.json ]; then
if grep -q \"react\" package.json; then echo "⚛️ React"
elif grep -q \"vue\" package.json; then echo "🖖 Vue"
elif grep -q \"angular\" package.json; then echo "🅰️ Angular"
elif grep -q \"next\" package.json; then echo "▲ Next.js"
else echo "📦 Node.js"
fi
elif [ -f Cargo.toml ]; then echo "🦀 Rust"
elif [ -f go.mod ]; then echo "🐹 Go"
elif [ -f requirements.txt ]; then echo "🐍 Python"
elif [ -f Gemfile ]; then echo "💎 Ruby"
else echo "📁 Project"
fi
"""
when = "true"
style = "bold cyan"
format = "[$output ]($style)"
description = "プロジェクトタイプの自動検出"
# 環境変数に基づく警告表示
[custom.env_warning]
command = "echo '⚠️ PRODUCTION'"
when = "test \"$NODE_ENV\" = \"production\" -o \"$RAILS_ENV\" = \"production\""
style = "bold red blink"
format = "[$output ]($style)"
description = "本番環境警告"
# Git操作のショートカット表示
[custom.git_shortcuts]
command = """
if [ -d .git ]; then
MODIFIED=$(git status --porcelain | grep -c '^.M')
UNTRACKED=$(git status --porcelain | grep -c '^??')
if [ $MODIFIED -gt 0 ] || [ $UNTRACKED -gt 0 ]; then
echo "💡 gs=status | ga=add | gc=commit"
fi
fi
"""
when = "test -d .git"
style = "dimmed white"
format = "\n[$output]($style)"
description = "Git操作のヒント"
# タスクランナー検出
[custom.task_runner]
command = """
RUNNERS=""
[ -f package.json ] && RUNNERS="npm/yarn "
[ -f Makefile ] && RUNNERS="${RUNNERS}make "
[ -f Taskfile.yml ] && RUNNERS="${RUNNERS}task "
[ -f justfile ] && RUNNERS="${RUNNERS}just "
echo $RUNNERS
"""
when = "test -f package.json -o -f Makefile -o -f Taskfile.yml -o -f justfile"
symbol = "🏃 "
style = "bold green"
format = "[$symbol($output)]($style)"
description = "利用可能なタスクランナー"
# システムリソース監視
[custom.cpu_temp]
command = """
if [ -f /sys/class/thermal/thermal_zone0/temp ]; then
TEMP=$(cat /sys/class/thermal/thermal_zone0/temp)
TEMP_C=$((TEMP / 1000))
if [ $TEMP_C -gt 80 ]; then
echo "🔥 ${TEMP_C}°C"
elif [ $TEMP_C -gt 60 ]; then
echo "🌡️ ${TEMP_C}°C"
fi
fi
"""
when = "test -f /sys/class/thermal/thermal_zone0/temp"
style = "bold red"
format = "[$output ]($style)"
description = "CPU温度警告"
# ディスク使用量警告
[custom.disk_usage]
command = """
USAGE=$(df -h / | awk 'NR==2 {print $5}' | sed 's/%//')
if [ $USAGE -gt 90 ]; then
echo "💾 ${USAGE}%"
elif [ $USAGE -gt 80 ]; then
echo "💿 ${USAGE}%"
fi
"""
when = "true"
style = "bold yellow"
format = "[$output ]($style)"
description = "ディスク使用量"
shell = ["bash", "--noprofile", "--norc"]
# チーム共通設定のインポート
# ~/.config/starship-team.toml を作成して共有
[env_var.STARSHIP_CONFIG]
format = ""
default = "~/.config/starship-team.toml"
# チームメンバー識別
[custom.team_member]
command = "echo $USER | sed 's/@.*//'"
when = "true"
symbol = "👤 "
style = "bold blue"
format = "[$symbol($output )]($style)"
description = "チームメンバー名"
# ペアプログラミングモード
[custom.pair_programming]
command = "echo '👥 Pairing'"
when = "test -n \"$PAIR_PROGRAMMING\""
style = "bold magenta"
format = "[$output ]($style)"
description = "ペアプログラミング中"
多くのモジュールを有効にすると、プロンプトの表示が遅くなる可能性があります。 以下の最適化テクニックを適用して、高速性を維持しましょう。
# キャッシュの活用
[custom.cached_info]
command = """
# 5分間キャッシュする例
CACHE_FILE="/tmp/starship_cache_$USER"
CACHE_AGE=300
if [ -f "$CACHE_FILE" ]; then
AGE=$(($(date +%s) - $(stat -f %m "$CACHE_FILE" 2>/dev/null || stat -c %Y "$CACHE_FILE")))
if [ $AGE -lt $CACHE_AGE ]; then
cat "$CACHE_FILE"
exit 0
fi
fi
# 重い処理をここに記述
RESULT="Heavy computation result"
echo "$RESULT" | tee "$CACHE_FILE"
"""
when = "true"
style = "bold green"
format = "[$output ]($style)"
description = "キャッシュされた情報"
# 非同期実行の活用
[jobs]
symbol = "+ "
number_threshold = 1
symbol_threshold = 1
style = "bold blue"
format = "[$symbol$number]($style) "
# グローバル設定
scan_timeout = 30
command_timeout = 500
# 重いコマンドを使うモジュールの無効化
[package]
disabled = true
# 条件付き表示
[aws]
disabled = false
format = '[$symbol($profile )(\($region\) )]($style)'
style = "bold yellow"
[aws.region_aliases]
us-east-1 = "va"
us-west-2 = "pdx"
# プロンプトの表示時間を計測
starship timings
# 特定モジュールの実行時間を確認
starship explain
# 設定の検証
starship config
Starship には多数の公式プリセットが用意されています。
チャートを読み込み中...
# プリセット一覧を確認
starship preset -l
# プリセットを適用
starship preset nerd-font-symbols -o ~/.config/starship.toml
# プリセットをプレビュー
starship preset tokyo-night
# macOS向け最適化
[custom.macos_app]
command = """
osascript -e 'tell application "System Events" to get name of first application process whose frontmost is true'
"""
when = "test $(uname) = 'Darwin'"
symbol = " "
style = "bold white"
format = "[$symbol($output )]($style)"
description = "アクティブなアプリケーション"
# Homebrew状態
[custom.brew_updates]
command = "brew outdated | wc -l | tr -d ' '"
when = "test $(uname) = 'Darwin' && which brew > /dev/null"
symbol = "🍺 "
style = "bold yellow"
format = "[$symbol($output updates )]($style)"
description = "Homebrewの更新可能なパッケージ数"
# WSL環境検出
[custom.wsl]
command = "echo 'WSL'"
when = "test -f /proc/sys/fs/binfmt_misc/WSLInterop"
symbol = " "
style = "bold green"
format = "[$symbol$output ]($style)"
description = "WSL環境インジケーター"
# Windows側のパス表示
[custom.windows_path]
command = "wslpath -w $(pwd) 2>/dev/null || echo ''"
when = "test -f /proc/sys/fs/binfmt_misc/WSLInterop"
symbol = " "
style = "dimmed white"
format = "[$symbol($output )]($style)"
description = "Windowsパス"
# SSH接続の視覚化
[hostname]
ssh_only = true
ssh_symbol = "🌐 "
style = "bold green"
format = "[$ssh_symbol$hostname]($style) "
# リモート環境でのパフォーマンス設定
[custom.remote_optimized]
command = "echo $SSH_CLIENT | cut -d' ' -f1"
when = "test -n \"$SSH_CLIENT\""
symbol = "📡 "
style = "bold yellow"
format = "[$symbol($output )]($style)"
description = "SSH接続元IP"
# タイムアウトの調整
scan_timeout = 10 # リモート環境では短めに
command_timeout = 100 # コマンドのタイムアウトも短めに
# Tokyo Night テーマ
[palettes.tokyo_night]
red = "#f7768e"
green = "#9ece6a"
yellow = "#e0af68"
blue = "#7aa2f7"
purple = "#bb9af7"
cyan = "#7dcfff"
white = "#c0caf5"
black = "#15161e"
bright_red = "#f7768e"
bright_green = "#9ece6a"
bright_yellow = "#e0af68"
bright_blue = "#7aa2f7"
bright_purple = "#bb9af7"
bright_cyan = "#7dcfff"
bright_white = "#c0caf5"
bright_black = "#414868"
palette = "tokyo_night"
[character]
success_symbol = "[❯](bold green)"
error_symbol = "[❯](bold red)"
# Dracula テーマ
[palettes.dracula]
background = "#282a36"
current = "#44475a"
foreground = "#f8f8f2"
comment = "#6272a4"
cyan = "#8be9fd"
green = "#50fa7b"
orange = "#ffb86c"
pink = "#ff79c6"
purple = "#bd93f9"
red = "#ff5555"
yellow = "#f1fa8c"
palette = "dracula"
[directory]
style = "bold cyan"
[git_branch]
style = "bold purple"
[git_status]
style = "bold red"
# Nord テーマ
[palettes.nord]
# Polar Night
nord0 = "#2e3440"
nord1 = "#3b4252"
nord2 = "#434c5e"
nord3 = "#4c566a"
# Snow Storm
nord4 = "#d8dee9"
nord5 = "#e5e9f0"
nord6 = "#eceff4"
# Frost
nord7 = "#8fbcbb"
nord8 = "#88c0d0"
nord9 = "#81a1c1"
nord10 = "#5e81ac"
# Aurora
nord11 = "#bf616a"
nord12 = "#d08770"
nord13 = "#ebcb8b"
nord14 = "#a3be8c"
nord15 = "#b48ead"
palette = "nord"
[username]
style_user = "bold nord4"
[directory]
style = "bold nord9"
# Gruvbox テーマ
[palettes.gruvbox_dark]
# Dark colors
bg0 = "#282828"
bg1 = "#3c3836"
bg2 = "#504945"
bg3 = "#665c54"
bg4 = "#7c6f64"
# Light colors
fg0 = "#fbf1c7"
fg1 = "#ebdbb2"
fg2 = "#d5c4a1"
fg3 = "#bdae93"
fg4 = "#a89984"
# Bright colors
red = "#fb4934"
green = "#b8bb26"
yellow = "#fabd2f"
blue = "#83a598"
purple = "#d3869b"
aqua = "#8ec07c"
orange = "#fe8019"
palette = "gruvbox_dark"
[character]
success_symbol = "[➜](bold green)"
error_symbol = "[✗](bold red)"
問題 | 原因 | 解決策 |
---|---|---|
アイコンが表示されない | Nerd Fontsが未インストール | Nerd Fontsをインストールし、ターミナルで設定 |
プロンプトが遅い | 重いモジュールが有効 | 不要なモジュールを無効化、タイムアウトを調整 |
設定が反映されない | 設定ファイルの構文エラー | starship configで検証、TOMLの構文を確認 |
特定の言語が検出されない | バイナリパスの問題 | detect_filesやdetect_extensionsを設定 |
# デバッグログを有効化
export STARSHIP_LOG=trace
# 設定の検証
starship config
# モジュールの動作確認
starship module <module_name>
# 詳細なデバッグ情報
export STARSHIP_LOG=trace
starship prompt
# 特定モジュールのデバッグ
starship module git_branch
starship module custom.my_module
# パフォーマンスプロファイリング
starship timings --format json > timings.json
# 設定の検証とフォーマット
starship config --format
# バージョン管理のための設定
# ~/.config/starship.toml
# 設定のメタ情報
[custom.config_version]
command = "echo 'v2.0'"
when = "true"
format = "# Starship Config $output\n"
disabled = true # コメントとして使用
# モジュラー設定の読み込み
# 各環境用の設定を別ファイルで管理
# starship.toml
# starship-work.toml
# starship-personal.toml
# チーム共通の設定をGitで管理
git clone https://github.com/team/starship-config
ln -s ~/starship-config/starship.toml ~/.config/starship.toml
# 個人設定のオーバーライド
cat >> ~/.config/starship.toml << EOF
# Personal overrides
[username]
show_always = true
style_user = "bold purple"
EOF
# GitHub Actions example
name: CI with Starship
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Starship
run: |
curl -sS https://starship.rs/install.sh | sh -s -- -y
echo 'eval "$(starship init bash)"' >> ~/.bashrc
- name: Run tests with enhanced prompt
run: |
source ~/.bashrc
# CIでの視覚的なフィードバック
export STARSHIP_CONFIG=./ci-starship.toml
./run-tests.sh
# セキュアな設定例
[custom.secure_info]
# APIキーなどの機密情報は環境変数から読む
command = "echo $MY_API_STATUS"
when = "test -n \"$MY_API_KEY\""
format = "[$output]($style) "
# コマンドに直接機密情報を含めない
# プロダクション環境の警告
[custom.prod_warning]
command = "echo '⚠️ PRODUCTION ENVIRONMENT'"
when = "test \"$ENVIRONMENT\" = \"production\""
style = "bold red blink"
format = "\n[$output]($style)\n"
Starship Prompt は、ターミナル体験を劇的に向上させる強力なツールです。
starship timings
で定期的にチェックデフォルト設定で使い始める
使用する言語のモジュールを有効化
Git情報の表示をカスタマイズ
独自の情報を表示するモジュールを作成
不要なモジュールの無効化と高速化
チーム全体で統一された設定を使用
Starship を導入してから、ターミナルでの作業効率が格段に上がりました。 git 情報が一目でわかるのは本当に便利です。
# .zshrcの設定(複雑)
ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(...)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(...)
# 多数の設定項目...
# パフォーマンス問題
# 起動時間: 200-500ms
# starship.tomlの設定(シンプル)
format = "$all$character"
[nodejs]
symbol = " "
# 高速パフォーマンス
# 起動時間: 10-50ms
# .zshrcの設定(複雑)
ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(...)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(...)
# 多数の設定項目...
# パフォーマンス問題
# 起動時間: 200-500ms
# starship.tomlの設定(シンプル)
format = "$all$character"
[nodejs]
symbol = " "
# 高速パフォーマンス
# 起動時間: 10-50ms