はじめに
tmuxでのプラグインの導入方法と参考用に現在利用しているプラグインとその設定を紹介したいと思います。
tmuxの基礎的な部分は下記で解説しています。

【入門】tmux始めてみる
はじめに tmuxについて、基本的なことを理解して使えるようになるまでを解説していこうと思います。 tmuxとは tmuxとは、端末多重化ソフトウェア(Terminal Multiplexer)です。 端末多重化ソフトウェアと言ってもわかり...
tmuxのプラグイン管理
tmuxではプラグインを利用することで見た目や操作方法をカスタマイズしやすくなります。
tpm
(Tmux Plugin Manager)を利用することで、プラグインの管理がしやすくなります。tmuxでプラグインを利用する場合はまずtpm
を導入するところから始まります。
tpm(Tmux Plugin Manager)の導入
まずはtpm
をgithubからクローンします。
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
tpmを利用するには.tmux.conf
で以下のように記述します。
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# tpmの初期化(tmux.confの下の方に記述する)
run '~/.tmux/plugins/tpm/tpm'
.tmux.conf
を変更したので読み込みます。
tmux source ~/.tmux.conf
これでプラグインを追加する準備はできました。
プラグインの追加
具体例として、以下のプラグインを追加してみます。
GitHub - tmux-plugins/tmux-pain-control: standard pane key-bindings for tmux
standard pane key-bindings for tmux. Contribute to tmux-plugins/tmux-pain-control development by creating an account on GitHub.
まずは.tmux.conf
にプラグインを追加します。
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# プラグインを追加
set -g @plugin 'tmux-plugins/tmux-pain-control'
# tpmの初期化(tmux.confの下の方に記述する)
run '~/.tmux/plugins/tpm/tpm'
.tmux.conf
を変更したら、prefix + I
でプラグインの取得できます。
便利そうなプラグインは以下でまとめられているので、参照してください。
GitHub - rothgar/awesome-tmux: A list of awesome resources for tmux
A list of awesome resources for tmux. Contribute to rothgar/awesome-tmux development by creating an account on GitHub.
設定
参考程度に現在私の利用しているプラグインと.tmux.conf
を紹介します。
tpm
:tmuxのプラグインマネージャーtmux-sensible
:おすすめオプションを設定してくれるtmux-yank
:tmuxからクリップボードにコピー可能にtmux-copycat
:検索を便利にtmux-pain-control
:vimっぽいペインの移動を可能にdracula/tmux
:draculaのテーマ
GitHub - tmux-plugins/tpm: Tmux Plugin Manager
Tmux Plugin Manager. Contribute to tmux-plugins/tpm development by creating an account on GitHub.
GitHub - tmux-plugins/tmux-sensible: basic tmux settings everyone can agree on
basic tmux settings everyone can agree on. Contribute to tmux-plugins/tmux-sensible development by creating an account on GitHub.
GitHub - tmux-plugins/tmux-yank: Tmux plugin for copying to system clipboard. Works on OSX, Linux and Cygwin.
Tmux plugin for copying to system clipboard. Works on OSX, Linux and Cygwin. - GitHub - tmux-plugins/tmux-yank: Tmux plugin for copying to system clipboard. Wor...
GitHub - tmux-plugins/tmux-copycat: A plugin that enhances tmux search
A plugin that enhances tmux search. Contribute to tmux-plugins/tmux-copycat development by creating an account on GitHub.
GitHub - tmux-plugins/tmux-pain-control: standard pane key-bindings for tmux
standard pane key-bindings for tmux. Contribute to tmux-plugins/tmux-pain-control development by creating an account on GitHub.
GitHub - dracula/tmux: 🧛🏻♂️ Dark theme for tmux
🧛🏻♂️ Dark theme for tmux. Contribute to dracula/tmux development by creating an account on GitHub.
.tmux.conf
は以下のようになっています。
# ---------------------------------------------------------
# plugin
# ---------------------------------------------------------
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'dracula/tmux'
set -g @dracula-plugins "battery cpu-usage ram-usage weather time"
# ---------------------------------------------------------
# basic
# ---------------------------------------------------------
# tmux起動時のシェルをzshに
set-option -g default-shell /bin/zsh
# 256色表示可能に変更
set-option -g default-terminal screen-256color
set -g terminal-overrides 'xterm:colors=256'
# PrefixをCtrl-qに変更
set -g prefix C-q
unbind C-b
# ---------------------------------------------------------
# mapping
# ---------------------------------------------------------
# .tmux.confの読み込み
bind-key r source-file ~/.tmux.conf\; display-message "$HOME/.tmux.conf reloaded!"
# ---------------------------------------------------------
# copy mode
# ---------------------------------------------------------
setw -g mode-keys vi
# ---------------------------------------------------------
# status bar
# ---------------------------------------------------------
# dracula options
set -g @dracula-left-icon-padding 2
set -g @dracula-show-location false
set -g @dracula-show-fahrenheit false
set -g @dracula-show-timezone false
set -g @dracula-show-flags true
set -g @dracula-military-time true
# ---------------------------------------------------------
# initialize tmux plugin manager
# ---------------------------------------------------------
run '~/.tmux/plugins/tpm/tpm'
見た目は以下のような感じになります。
ちなみに、左側のコマンドはbrew install neofetch
で取得でき、右下の時計はprefix + t
で表示できます。
参考
- rothgar/awesome-tmux: A list of awesome resources for tmux
- tmux-plugins/tpm: Tmux Plugin Manager
- tmux-plugins/tmux-sensible: basic tmux settings everyone can agree on
- tmux-plugins/tmux-yank: Tmux plugin for copying to system clipboard. Works on OSX, Linux and Cygwin.
- tmux-plugins/tmux-copycat: A plugin that enhances tmux search
- tmux-plugins/tmux-pain-control: standard pane key-bindings for tmux
- dracula/tmux: 🧛🏻♂️ Dark theme for tmux
- Dark theme for tmux and 218+ apps — Dracula