テーマ

tmuxのステータスバーやペイン、ウィンドウの色をカスタマイズすることで、使いやすいテーマを作成できます。

カラースキーム基本

Tmuxで使える色

色名説明
black
red
green
yellow
blue
magentaマゼンタ
cyanシアン
white
colour0-255256色モード
#RRGGBB16進数カラー(Tmux 3.2+)

ステータスバーのカラー設定

# 背景色と文字色
set-option -g status-style bg=colour235,fg=colour246

# アクティブなウィンドウのスタイル
set-window-option -g window-status-current-style bg=colour25,fg=white,bold

# 非アクティブなウィンドウのスタイル
set-window-option -g window-status-style bg=colour235,fg=colour246

テーマ例

モダンダークテーマ

# ~/.tmux.conf

# ステータスバー
set-option -g status-bg "#1e1e1e"
set-option -g status-fg "#ffffff"
set-option -g status-position top
set-option -g status-interval 1

# アクティブペインのボーダー
set-option -g pane-active-border-style "fg=#007acc"
set-option -g pane-border-style "fg=#333333"

# ウィンドウ
set-window-option -g window-status-style bg="#333333",fg="#cccccc"
set-window-option -g window-status-current-style bg="#007acc",fg="#ffffff",bold

# ステータスレイアウト
set-option -g status-left " #[fg=#ff6b6b]#S#[fg=#ffffff] "
set-option -g status-right " #[fg=#51cf66]%Y-%m-%d#[fg=#ffffff] | #[fg=#74c0fc]%H:%M:%S#[fg=#ffffff] "

# ウィンドウ分割ペイン枠
set-option -g display-panes-active-colour "#007acc"
set-option -g display-panes-colour "#333333"

ミニマルテーマ

# ~/.tmux.conf

# シンプルな背景と文字
set-option -g status-bg black
set-option -g status-fg white

# ステータスレイアウト(シンプル)
set-option -g status-left "[#S] "
set-option -g status-right "%H:%M "

# ペインボーダー(目立たない)
set-option -g pane-border-style fg=white
set-option -g pane-active-border-style fg=yellow

Dracula テーマ

# ~/.tmux.conf (Dracula-inspired)

# Colors
COLOR_BACKGROUND="#282a36"
COLOR_FOREGROUND="#f8f8f2"
COLOR_ACCENT="#ff79c6"
COLOR_SELECTION="#44475a"

# Status bar
set-option -g status-bg $COLOR_BACKGROUND
set-option -g status-fg $COLOR_FOREGROUND
set-option -g status-left "#[bg=$COLOR_ACCENT,fg=$COLOR_BACKGROUND] #S #[bg=$COLOR_BACKGROUND] "
set-option -g status-right "#[fg=$COLOR_ACCENT]%H:%M#[fg=$COLOR_FOREGROUND] "

# Window status
set-window-option -g window-status-style bg=$COLOR_SELECTION,fg=$COLOR_FOREGROUND
set-window-option -g window-status-current-style bg=$COLOR_ACCENT,fg=$COLOR_BACKGROUND,bold

# Pane borders
set-option -g pane-border-style fg=$COLOR_SELECTION
set-option -g pane-active-border-style fg=$COLOR_ACCENT

ステータスバーのレイアウト

左側(セッション情報)

set-option -g status-left "#[fg=colour2]#S#[fg=default] "

変数:

右側(時刻・日付)

set-option -g status-right "%Y-%m-%d %H:%M:%S"

フォーマット:

センター(ウィンドウ一覧)

set-option -g status-justify centre

ウィンドウスタイル

ウィンドウ名の表示形式

set-window-option -g window-status-format "#I:#{b:pane_current_path} "
set-window-option -g window-status-current-format "#[bold]#I:#{b:pane_current_path}#[default] "

変数:

ペインセパレータ

ペイン間のボーダーをカスタマイズ

# デフォルトのセパレータ
set-option -g pane-border-lines single

# 太いセパレータ
set-option -g pane-border-lines heavy

# アスキーセパレータ
set-option -g pane-border-lines ascii

テーマプリセット

公開されているテーマを使用することもできます。GitHubで「tmux-theme」や「tmux-colors」で検索できます。

テーマ設定ファイルの管理

テーマを別ファイルで管理する方法:

# ~/.tmux.conf

# テーマファイルを読み込み
source-file ~/.tmux/theme-dracula.conf

# または条件分岐
if-shell "test -f ~/.tmux/theme-dark.conf" {
    source-file ~/.tmux/theme-dark.conf
}

~/.tmux/theme-dracula.conf に上記のDraculaテーマを保存して使用できます。

カラーテストスクリプト

256色で利用可能な色を確認:

for i in {0..255}; do
    printf "\x1b[48;5;${i}m \x1b[0m"
done

これでtmuxで使用可能なすべての色が表示されます。