Skip to content

Instantly share code, notes, and snippets.

@ballistyx
Created November 14, 2015 12:57
Show Gist options
  • Save ballistyx/5d6866ca7f8ac27ade17 to your computer and use it in GitHub Desktop.
Save ballistyx/5d6866ca7f8ac27ade17 to your computer and use it in GitHub Desktop.
#################################################
#
# 外道式tmux設定&重要操作メモ
# modified by ballistyx
# - 操作メモはデフォルトではなく設定変更済みに対する説明
#########
#
# メモ
#
# C- と M- の意味
# C-* ... Ctrl + *
# M-* ... Alt + *
# bind-key の -r オプション
# repeat-timeミリ秒の間、2度目以降はPrefixを入力せず
# 連続して上下左右を含む同操作を行うことができる
# プレフィックスは Pre と表記
# この設定では Ctrl-t にしてある
#########
#
# セッション管理
#
# 作成
# tmux
# 名前付き
# tmux new-session -s $SessionName
# 一覧
# tmux ls
# 削除
# tmux kill-session -t $SessionName
# or
# Pre q
# 名前変更
# Pre $
# or
# Pre :rename $NewSessionName
# アタッチ
# tmux a -t $SessionName
# デタッチ
# Pre d
# セッション共有
#
# ホストユーザ
# tmux -S /tmp/tmux-shared.sock
# chmod 777 /tmp/tmux-shared.sock
# Pre :rename $NewSessionName
# ゲストユーザ(ホストユーザの再アタッチも)
# tmux -S /tmp/tmux-shared.sock a
#########
#
# ウィンドウ管理
#
# 追加
# Pre c
# 削除
# Pre K
# 名前変更
# Pre ,
# 一覧表示と選択
# Pre w
# 次に移動
# Pre n
# 前に移動
# Pre p
# 番号へ移動
# Pre $Number
# ウィンドウ自体を別セッションへ移動
# Pre . $DstSessionName
# or
# tmux move-window -s $SrcSessionName:$WindowNumber -t $DstSessionName:
# or
# tmux move-window -s $SrcSessionName:$WindowName -t $DstSessionName:
#########
#
# ペイン管理
#
# 縦分割
# Pre -
# 横分割
# Pre |
# 分割解除
# Pre !
# 削除
# Pre k
# or
# exit
# 番号表示
# Pre i
# 配置変更
#
# 順切替
# Pre Space
# 縦割り
# Pre M-1
# 横割り
# Pre M-2
# メイン+縦割り
# Pre M-3
# メイン+横割り
# Pre M-4
# 平均タイル型
# Pre M-5
# フォーカスの移動
# Pre 十字キー
# ペイン自体の移動
#
# 前
# Pre {
# 後
# Pre }
# 窓サイズ変更
# Pre Alt + 十字キー
# ペインのウィンドウ間移動
#
# 送る
# Pre :joinp -t :$WindowNumber
# 受ける
# Pre :joinp -s :$WindowNumber
# 通常はアクティブペインを取ってくる
# ペインの指定までしたい場合は
# :$WindowNumber.$PaneNumber
# マウスによるペイン操作切替
#
# デフォOFFで、マウスで文字列選択コピー可能
#
# ONにするとマウスでペイン選択、枠でペインサイズ変更、
# ウィンドウ名をクリックで選択可能になる
#
# ON
# Pre m
# OFF
# Pre M
# 全ペインへの同時キータッチ切替
# vi貼り付けでは1つにしか効果ない
#
# ON
# Pre e
# OFF
# Pre E
#########
#
# コピーモード
#
# 開始
# Pre [
# 始点決定
# Space
# 移動
# ←↓↑→
# or
# h j k l
# 終点決定
# Enter
# 貼り付け
# Pre ]
#########
#
# その他
#
# マニュアル
# man tmux
# 現在の設定確認
# Pre ?
# 設定ファイル再読み込み
# Pre r
#################################################
#
# 基本設定
#
# プレフィックス変更
set-option -g prefix C-t
bind-key C-t send-prefix
unbind-key C-b
# シェルの指定
set-option -g default-shell /bin/bash
set-option -g default-command /bin/bash
# ペイン開始番号
set-option -g base-index 1
# -r の連続入力待機ミリ秒。デフォは500
set-option -g repeat-time 1000
# 256色表示
set-option -g default-terminal screen-256color
# コピペ操作モードvi
# Pre+[ => space => Enter => Pre+]
setw -g mode-keys vi
# 文字コード
set-window-option -g utf8 on
set-window-option -g status-utf8 on
# prefix + r で設定ファイルを再読み込み
bind r source-file ~/.tmux.conf \; display-message "Reloaded config !!"
#################################################
#
# モード切替設定
#
# ペイン同時入力切り替え
set-option -g synchronize-panes off
bind e setw synchronize-panes on
bind E setw synchronize-panes off
# マウス操作切替
set-option -g mode-mouse off
set-option -g mouse-select-pane off
set-option -g mouse-resize-pane off
set-option -g mouse-select-window off
bind-key m \
set -g mode-mouse on \; \
set -g mouse-select-pane on \; \
set -g mouse-resize-pane on \; \
set -g mouse-select-window on \; \
display "Mouse: ON"
bind-key M \
set -g mode-mouse off \; \
set -g mouse-select-pane off \; \
set -g mouse-resize-pane off \; \
set -g mouse-select-window off \; \
display "Mouse: OFF"
#################################################
#
# ステータスバー
#
# 描画更新間隔秒。デフォルトは15秒
set-option -g status-interval 10
# ステータスバーの左右の最大長。デフォルトはleftが10, rightが40
set-option -g status-left-length 30
set-option -g status-right-length 60
# ステータスバーの表示と色
set -g status-right "[#h# ] %Y/%m/%d %H:%M"
set -g status-bg colour144
set -g status-fg black
set -g status-left-bg magenta
set -g status-left-fg black
set -g status-right-bg cyan
set -g status-right-fg black
#################################################
#
# ペイン
#
# 区切り線のスタイル
set -g pane-active-border-bg green
set -g pane-active-border-fg red
set -g pane-border-bg colour7
set -g pane-border-fg black
setw -g window-status-current-fg blue
#################################################
#
# キーバインド
#
# Pre - で縦分割
# Pre | で横分割
unbind-key %
unbind-key '"'
bind-key - split-window -v
bind-key | split-window -h
# Pre i でペイン番号を大きく表示
bind-key i display-panes
# ペイン自体の前後移動(-r 追加)
bind-key -r { swap-pane -U
bind-key -r } swap-pane -D
#
# ペインサイズ変更
#
bind-key -r M-Up resize-pane -U 5
bind-key -r M-Down resize-pane -D 5
bind-key -r M-Left resize-pane -L 20
bind-key -r M-Right resize-pane -R 20
#
# Ctrl押しっぱでも動作するように
#
bind-key C-c new-window
bind-key C-d detach
bind-key C-n next-window
bind-key C-p previous-window
#
# 各種終了
#
# Pre kでそのペインをkillする
bind-key k confirm-before 'kill-pane'
# Pre Kでそのウィンドウをkillする
bind-key K confirm-before 'kill-window'
# Pre qでそのセッションをkill-sessionする
bind-key q confirm-before 'kill-session'
# Pre C-qでtmuxそのもの(サーバとクライアント)をkillする
bind-key C-q confirm-before 'kill-server'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment