LoginSignup
4
2

More than 3 years have passed since last update.

tmuxにプラグイン(TPM)のインストールと設定

Last updated at Posted at 2020-05-15

tmuxにTmux Plugin Manager(TPM)のインストールと設定を行います。

Ubuntuにtmuxをインストール

$ sudo apt install tmux

tmuxのバージョンの確認

$ tmux -V
tmux 3.0a

Tmux Plugin Managerをインストール

1. githubからTPMリポジトリをクローンする

$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

2. tmuxの設定ファイルを以下のようにする

$ cat ~/.tmux.conf 
# tmuxのウィンドウモードをviにする
set-window-option -g mode-keys vi

# 新規ウィンドウを同じディレクトリで作業する 
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}" -v
bind '%' split-window -c "#{pane_current_path}" -h

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# ペイン操作のキーバインド追加
set -g @plugin 'tmux-plugins/tmux-pain-control'
# tmux環境の保存と復元
set -g @plugin 'tmux-plugins/tmux-resurrect'
# 表示内容を正規表現で検索
set -g @plugin 'tmux-plugins/tmux-copycat'
# システムのクリップボードにコピー
set -g @plugin 'tmux-plugins/tmux-yank'
# ハイライトしているファイルやURLを開く
set -g @plugin 'tmux-plugins/tmux-open'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'

tmux設定ファイル再読み込む

$ tmux source ~/.tmux.conf

または

prefix + Iキー

現在のキーバインドの確認

$ tmux list-keys | head -30
bind-key    -T copy-mode    C-Space               send-keys -X begin-selection
bind-key    -T copy-mode    C-a                   send-keys -X start-of-line
bind-key    -T copy-mode    C-b                   send-keys -X cursor-left
bind-key    -T copy-mode    C-c                   send-keys -X cancel
bind-key    -T copy-mode    C-e                   send-keys -X end-of-line
bind-key    -T copy-mode    C-f                   send-keys -X cursor-right
bind-key    -T copy-mode    C-g                   send-keys -X clear-selection
bind-key    -T copy-mode    C-k                   send-keys -X copy-end-of-line
bind-key    -T copy-mode    C-n                   send-keys -X cursor-down
bind-key    -T copy-mode    C-p                   send-keys -X cursor-up
bind-key    -T copy-mode    C-r                   command-prompt -i -I "#{pane_search_string}" -p "(search up)" "send -X search-backward-incremental \"%%%\""
bind-key    -T copy-mode    C-s                   command-prompt -i -I "#{pane_search_string}" -p "(search down)" "send -X search-forward-incremental \"%%%\""
bind-key    -T copy-mode    C-v                   send-keys -X page-down
bind-key    -T copy-mode    C-w                   send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode    Escape                send-keys -X cancel
bind-key    -T copy-mode    Space                 send-keys -X page-down
bind-key    -T copy-mode    ,                     send-keys -X jump-reverse
bind-key    -T copy-mode    \;                    send-keys -X jump-again
bind-key    -T copy-mode    F                     command-prompt -1 -p "(jump backward)" "send -X jump-backward \"%%%\""
bind-key    -T copy-mode    N                     send-keys -X search-reverse
bind-key    -T copy-mode    R                     send-keys -X rectangle-toggle
bind-key    -T copy-mode    T                     command-prompt -1 -p "(jump to backward)" "send -X jump-to-backward \"%%%\""
bind-key    -T copy-mode    Y                     send-keys -X copy-pipe-and-cancel "tmux display-message 'Error! tmux-yank dependencies not installed!'"
bind-key    -T copy-mode    f                     command-prompt -1 -p "(jump forward)" "send -X jump-forward \"%%%\""
bind-key    -T copy-mode    g                     command-prompt -p "(goto line)" "send -X goto-line \"%%%\""
bind-key    -T copy-mode    n                     send-keys -X search-again
bind-key    -T copy-mode    q                     send-keys -X cancel
bind-key    -T copy-mode    t                     command-prompt -1 -p "(jump to forward)" "send -X jump-to-forward \"%%%\""
bind-key    -T copy-mode    y                     send-keys -X copy-pipe-and-cancel "tmux display-message 'Error! tmux-yank dependencies not installed!'"
bind-key    -T copy-mode    MouseDown1Pane        select-pane
4
2
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
4
2