4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

tmuxを使えるようにする

Last updated at Posted at 2019-07-05

tmuxのインストール

homebrewでインストールしました。

$ brew install tmux

.tmux.confの設定

tmuxは.tmux.confをいじることにより設定を変えることができます。
また、tmuxからコピーしたものをmacのクリップボードに移すために必要なreattach-to-user-namespaceをインストールします。

$ brew install reattach-to-user-namespace

プラグインマネージャーであるtpmをインストールします。

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

以下は現在自分が使っている.tmux.conf

.tmux.conf
# tmux起動時のシェルをzshにする
set-option -g default-shell /usr/local/bin/zsh

# tmuxを256色表示できるようにする
set-option -g default-terminal screen-256color
set -g terminal-overrides 'xterm:colors=256'

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

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

# ステータスバーをトップに配置する
set-option -g status-position top

# 左右のステータスバーの長さを決定する 
set-option -g status-left-length 90
set-option -g status-right-length 90

# #P => ペイン番号
# 最左に表示
set-option -g status-left '#H:[#P]'

# Wi-Fi、バッテリー残量、現在時刻
# 最右に表示
set -g status-right '#{battery_status_bg} Batt: #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M '

# ステータスバーを1秒毎に描画し直す
set-option -g status-interval 1

# センタライズ(主にウィンドウ番号など)
set-option -g status-justify centre

# ステータスバーの色を設定する
set-option -g status-bg "colour238"

# status line の文字色を指定する。
set-option -g status-fg "colour255"

# 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

# マウス操作を有効にする
set-option -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"


set -g @tpm_plugins '              \
  tmux-plugins/tpm                 \
  tmux-plugins/tmux-yank           \
  tmux-plugins/tmux-open           \
  tmux-plugins/tmux-resurrect      \
  tmux-plugins/tmux-battery        \
  tmux-plugins/tmux-pain-control   \
'

run-shell '~/.tmux/plugins/tpm/tpm'
4
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?