LoginSignup
244
241

More than 5 years have passed since last update.

tmuxで快適なターミナル生活を送ろう

Last updated at Posted at 2014-11-10

tmuxで快適なターミナル生活を送ろう

tmuxとは

仮想の中で仮想端末を管理するもの。
GNUScreenをより強化したイメージ。

  • 起動
tmux
  • tmuxのセッション一覧
tmux list-session
  • セッション番号を指定して起動していたtmuxを再起動
tmux attach -t セッション番号

コマンド一覧

※Ctrl-b はデフォルト設定なので、.tmux.conf等でPrefixを変更した場合はそちらの方をお使いください。

コマンド 説明
Ctrl-b ? ショートカット一覧
Ctrl-b d デタッチ
Ctrl-b w ウィンドウ一覧
Ctrl-b c ウィンドウ生成
Ctrl-b n 次のウィンドウへ
Ctrl-b p 前のウィンドウへ
Ctrl-b : コマンドモードへ
Ctrl-b [ コピーモード開始
Ctrl-b Ctrl-Space コピーモードでのコピー開始
Ctrl-b ESC-w コピーモードでのコピー終了
Ctrl-b ] コピーデータの貼付け
Ctrl-b q ペインのインジケータを表示
Ctrl-b t 時計表示
Ctrl-b % ウインドウを左右ペインへ分割
Ctrl-b " ウインドウを上下ペインへ分割
Ctrl-b o アクティブなペインの移動(次のペインへ移動)
Ctrl-b x ペインの破棄
Ctrl-b Space ペインレイアウトの変更(左右、上下)
Ctrl-b : resize-pane -U 数字 上部ペインのサイズ変更
Ctrl-b : resize-pane -D 数字 下部ペインのサイズ変更
Ctrl-b : resize-pane -L 数字 左ペインのサイズ変更
Ctrl-b : resize-pane -R 数字 右ペインのサイズ変更

.tmux.conf

.tmux.confとは、tmux起動時に呼び出される設定ファイルです。
~/.tmux.confに記述します。

.tmux.confの例

tmux.conf
# prefixキーをC-qに変更
set -g prefix C-q

# C-bのキーバインドを解除
unbind C-b

# vimのキーバインドでペインを移動する
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# vimのキーバインドでペインをリサイズする
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# | でペインを縦分割する
bind | split-window -h

# | でペインを縦分割する
bind - split-window -v

# 番号基準値を変更
set-option -g base-index 1

# マウス操作を有効にする
setw -g mode-mouse on
set -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mouse-select-window on

# ステータスバーの色を設定する
set -g status-fg white
set -g status-bg black

# コピーモードを設定する
## viのキーバインドを使用
setw -g mode-keys vi
244
241
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
244
241