Skip to content

Instantly share code, notes, and snippets.

@taichunmin
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taichunmin/f9ca40920b52b2b1bf10 to your computer and use it in GitHub Desktop.
Save taichunmin/f9ca40920b52b2b1bf10 to your computer and use it in GitHub Desktop.
tmux conf by PastLeo
# -------------------- PastLeo's tmux.conf ---------------------
#
# 蒐集各處資料製作而成
# 讓tmux有screen的操作方式
# 並且可以顯示CPU,RAM的使用情況
# (記得裝套件,詳情:https://github.com/tony/tmux-config 的 tmux-mem-cpu-load)
# tmux樹狀圖:
# tmux >> client (attach/detach) >> session >> window >> pane
#
# --------------------------------------------------------------
# Part 1 : 全域設定 --------------------------------------------
# scrollback buffer n lines 保留的行數
set -g history-limit 5000
# listen for activity on all windows
set -g bell-action any
# start window indexing at 1 window的編號起始設定為1,這樣在鍵盤上比較容易按得到
set -g base-index 1
# instructs tmux to expect UTF-8 sequences
setw -g utf8 on
set -g utf8 on
# tell tmux to use 256 colour terminal
set -g default-terminal "screen-256color"
# xterm-style function key sequences
setw -g xterm-keys on
# control automatic window renaming
setw -g automatic-rename off
# enable wm window titles
set -g set-titles on
# wm window title string (uses statusbar variables)
#set -g set-titles-string "tmux.#I.#W"
# don't close windows. just deactivate them. use respawn-window to reactivate.
#setw -g remain-on-exit on
# Part 2 : 快捷鍵設定 ------------------------------------------
# Set prefix key to Ctrl-a
# 按下 Ctrl+a 時進入操作tmux的狀態,下面的 bind-key 皆為 Ctrl+a 之後可下的指令
# Ctrl+b 是原始的設定, -g 代表設定設定到全世界
unbind-key C-b
set-option -g prefix C-s
set-option -g prefix C-a
# Key bindings
# use C-a again to send ctrl-a to inner session
bind-key C-a send-prefix
# open a man page in new window 當場分割畫面觀看使用手冊,按下q離開(同man)
bind-key / command-prompt "split-window 'exec man %%'"
# reload settings
bind-key R source-file ~/.tmux.conf
# detach client 保留 session 情況下離開 tmux
bind-key d detach
bind-key D detach
bind-key C-d detach
bind-key C-D detach
# 列出、選擇
# list/displays session/window/pane
bind-key | list-clients
# bind-key ~ list-sessions -F "[{=5:session_id}]: #S >> session_attached={=1:session_attached}"
# 雖然沒有很重要,但就是不知道為啥不能用= =
bind-key W list-window
bind-key E display-panes
# choose client/session/window
bind-key \ choose-client
bind-key ` choose-session
bind-key w choose-window
# 新增、刪除
# new window
bind-key C-c new-window
bind-key c new-window
# Split windows (Create pane) like vim
# vim's definition of a horizontal/vertical split is reversed from tmux's
bind-key s split-window -v
bind-key v split-window -h
# kill current pane/window/session/server
bind-key x confirm-before kill-window
bind-key q confirm-before kill-pane
bind-key X confirm-before kill-session
bind-key Q confirm-before kill-server
# 移動 (navigate)
# navigate windows using hl, and ctrl-hl
bind-key -r h select-window -t :-
bind-key -r l select-window -t :+
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
# toggle last window like screen
bind-key a last-window
# next window
bind-key -r n next-window
bind-key -r N next-window
bind-key -r C-n next-window
bind-key -r C-N next-window
bind-key -r Space next-window
bind-key -r "C-Space" next-window
# prev window
bind-key BSpace previous-window
# Cycle to next pane
bind-key -r Tab select-pane -t :.+
bind-key -r e select-pane -t :.+
# navigate panes using jk, and ctrl+jk
bind-key -r j select-pane -t :.-
bind-key -r k select-pane -t :.+
bind-key -r C-j select-pane -t :.-
bind-key -r C-k select-pane -t :.+
# 更改 (Rename,Resize)
# title (default key in tmux is ',')
bind-key A command-prompt "rename-window %%"
bind-key , command-prompt "rename-window %%"
# resize panes like vim
bind-key -r "left" resize-pane -L 3
bind-key -r "right" resize-pane -R 3
bind-key -r "up" resize-pane -U 1
bind-key -r "down" resize-pane -D 1
# default "<",">","+","="
# specific window layouts
bind-key -r y next-layout
bind-key o select-layout "active-only"
bind-key O select-layout "main-vertical"
# swap panes
bind-key -r J swap-pane -D
bind-key -r K swap-pane -U
# toogle a pane between full-screen and pane-size
# bind-key f resize-pane -Z
# bind-key F resize-pane -Z
# vi模式相關設定
# vi-style controls for copy mode
setw -g mode-keys vi
# copying and pasting 按下"["將進入vi模式,"]"將貼上
bind-key [ copy-mode
bind-key ] paste-buffer -s \015
# vi mode selecting and copying 和vi相同,v:選擇,y:複製
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
# list all paste buffers (default is #) 列出剪貼簿
bind-key P list-buffers
# choose buffer to paste interactively (default key was '=') 列出剪貼簿,並且選擇要貼上的
bind-key p choose-buffer
# disable mouse selection in copy mode
setw -g mode-mouse off
# Part 3 : Statusbar settings 狀態列設定 -----------------------
# use vi-style key bindings in the status line
set -g status-keys vi
# amount of time for which status line messages and other indicators
# are displayed. time is in milliseconds.
set -g display-time 2000
# default statusbar colors
set -g status-fg white
set -g status-bg default
set -g status-attr default
# default window title colors
setw -g window-status-fg white
setw -g window-status-bg default
setw -g window-status-attr dim
# active window title colors
setw -g window-status-current-fg cyan
setw -g window-status-current-bg default
#setw -g window-status-current-attr bright
setw -g window-status-current-attr underscore
# command/message line colors
set -g message-fg white
set -g message-bg black
set -g message-attr bright
# what to be displayed on the right status 右狀態列的設定:
set-option -g status-utf8 on
set -g status-interval 1
set -g status-right '} | %Y-%m-%d %H:%M:%S'
set -g status-right-length 60
# what to be displayed on the right status 右狀態列的設定:
set -g status-left-length 30
set-option -g status-left "#[fg=green]#(echo $USER)#[default].#[fg=blue]#h#[default] {"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment