Skip to content

Instantly share code, notes, and snippets.

@highemerly
Created August 15, 2019 05:31
Show Gist options
  • Save highemerly/a0887e1213667e31d0fb48d1824e8e90 to your computer and use it in GitHub Desktop.
Save highemerly/a0887e1213667e31d0fb48d1824e8e90 to your computer and use it in GitHub Desktop.
tmux設定
###############################################
## .TMUX.CONF
## Author: highemerly@handon.club
## Usage: put it at ~/.tmux.conf,
## comment out for your tmux version
## (default setting is for 2.9+),
## lanch tmux
################################################
###########
### Prefix Key
###########
# change prefix key (ctrl-b to ctrl-q)
unbind C-b
#enable ctrl-q
set -g prefix C-q
bind C-q send-prefix
###########
### Key Bind
###########
# move pain with vim key-bind
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# resize pain by vim key-bind
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
# split windows by | and -
bind | split-window -h
bind - split-window -v
############
### Copy and Paste
### In MacOS X, the feature of synchronizing clipboard is also enabled.
### To use, `brew install reattach-to-usernamespace' at Mac, and launch tmux on Mac.
############
# set brew package
############ Only version 2.5 or before ##############
#set-option -g default-command "reattach-to-user-namespace -l zsh"
######################################################
# change prefix key to vim key-bind only in copy-paste mode
setw -g mode-keys vi
# setup reattach-to-user-namespace
########### Only version 2.3 or before ###############
#bind-key -t vi-copy v begin-selection
#bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
#unbind -t vi-copy Enter
#bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
########### Only version 2.4, 2.5 ####################
#bind-key -t copy-mode-vi v begin-selection
#bind-key -t copy-mode-vi y copy-pipe "reattach-to-user-namespace pbcopy"
#unbind -t copy-mode-vi Enter
#bind-key -t copy-mode-vi Enter copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
########### Only version 2.6 or later ################
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"
#####################################################
# Vim settings on tmux session
#set-option -g default-command "reattach-to-user-namespace -l bash"
#############
### Design
#############
# 256color for vim
set-option -g default-terminal "screen-256color"
# change border color of pain and window
############ Only version 2.8 or before ###############
#set -g pane-border-fg green
#set -g pane-border-bg black
#set -g pane-active-border-fg white
#set -g pane-active-border-bg yellow
#setw -g window-status-current-fg white
#setw -g window-status-current-bg red
#setw -g window-status-current-attr bright
############ Only version 2.9 or later ################
set -g pane-border-style fg="green",bg="black"
set -g pane-active-border-style fg="white",bg="yellow"
setw -g window-status-current-style fg="white",bg="red","bright"
######################################################
# customize status bar (hostname, clocks)
set -g status-interval 1
set -g status-left-length 40
set -g status-left "#[fg=black,bg=colour51] #H:#S #[default]"
set -g status-justify centre
set -g status-right "#[fg=black] %y-%m-%d(%a) %H:%M:%S(%Z)"
# change window displays
set-window-option -g window-status-format " #I: #W "
###############
### Other Global Settings
###############
# change pain number (start 1, not 0)
set-option -g base-index 1
# enable mouse
########### Only version 2.0 or before ###########
#set -g mode-mouse on
#set -g mouse-select-pane on
#set -g mouse-resize-pane on
#set -g mouse-select-window on
########### Only version 2.1 or later ###########
set -g mouse on
bind -n WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
bind -n WheelDownPane select-pane -t= \; send-keys -M
#################################################
# follow the changes of terminal size
setw -g aggressive-resize on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment