├── README.md └── tmux.conf /README.md: -------------------------------------------------------------------------------- 1 | # k-tmux 2 | 3 | # Introduction 4 | 5 | A tmux conf, which can work with [k-vim](https://github.com/wklken/k-vim) 6 | 7 | 简要说明 [k-tmux](http://www.wklken.me/posts/2015/08/06/linux-tmux.html) 8 | 9 | # Screenshot 10 | 11 | ![screenshot](https://raw.githubusercontent.com/wklken/gallery/master/tmux/tmux.png) 12 | 13 | # Install 14 | 15 | NOTE: make sure your tmux version >= 2.5 16 | 17 | Recommend 18 | 19 | ``` 20 | 1. backup old tmux config if it is necessary 21 | 22 | cp ~/.tmux.conf ~/.tmux.conf_bak 23 | 24 | 2. just get the file 25 | 26 | curl https://raw.githubusercontent.com/wklken/k-tmux/master/tmux.conf > ~/.tmux.conf 27 | 28 | 3. Done, enjoy it 29 | ``` 30 | 31 | Use github 32 | 33 | ``` 34 | git clone https://github.com/wklken/k-tmux.git 35 | ln -s $PWD/k-tmux/tmux.conf ~/.tmux.conf 36 | ``` 37 | 38 | # Donation 39 | 40 | You can Buy me a coffee:) [link](http://www.wklken.me/pages/donation.html) 41 | 42 | 43 | ------------------------ 44 | ------------------------ 45 | 46 | wklken 47 | 48 | Email: wklken@yeah.net 49 | 50 | Github: https://github.com/wklken 51 | 52 | Blog: [http://www.wklken.me](http://www.wklken.me) 53 | 54 | 2015-08-06 ShenZheng 55 | -------------------------------------------------------------------------------- /tmux.conf: -------------------------------------------------------------------------------- 1 | #========================================== 2 | # URL: https://github.com/wklken/k-tmux 3 | # Author: wklken 4 | # Version: 0.1.1 5 | # Email: wklken@yeah.net 6 | # ReadMe: README.md 7 | # Donation: http://www.wklken.me/pages/donation.html 8 | # Last_modify: 2015-08-06 9 | #========================================== 10 | # Dependecny: 11 | # 1. brew install reattach-to-user-namespace 12 | # 2. gem install tmuxinator 13 | # 3. vim: christoomey/vim-tmux-navigator 14 | 15 | 16 | #--------------------------- base config begin ------------------------------- 17 | 18 | # 全局设置 19 | setw -g xterm-keys on 20 | # Using set -gq instead of set -g will silence the unknown option error, while still setting it on old versions of tmux 21 | set -gq status-utf8 on # enable utf-8 22 | set-option -g default-terminal "screen-256color" # use 256 colors 23 | set-option -g history-limit 100000 # scrollback buffer n lines 24 | set-option -g display-time 5000 # 提示信息的持续时间;设置足够的时间以避免看不清提示,单位为毫秒 25 | set-option -g repeat-time 1000 # 控制台激活后的持续时间;设置合适的时间以避免每次操作都要先激活控制台,单位为毫秒 26 | set-window-option -g display-panes-time 1500 27 | set-option -g repeat-time 0 # Allow the arrow key to be used immediately after changing windows 28 | 29 | set-option -g renumber-windows on # window 0, 1, 2, remove 1, renumber to 0, 1 30 | 31 | # Set window notifications 32 | setw -g monitor-activity on 33 | set -g visual-activity on 34 | 35 | # use C-a, since it's on the home row and easier to hit than C-b 36 | set-option -g prefix C-a 37 | unbind-key C-b 38 | bind-key C-a send-prefix 39 | # make `ctrl+a ctrl+a` to move to beginning of the line 40 | bind a send-prefix 41 | 42 | # bind a reload key: prefix+r 43 | bind R source-file ~/.tmux.conf \; display-message "Config reloaded.." 44 | 45 | 46 | 47 | # -------------------------------- session begin -------------------------------- 48 | bind -r ( switch-client -p 49 | bind -r ) switch-client -n 50 | # -------------------------------- session end -------------------------------- 51 | 52 | # -------------------------------- window begin -------------------------------- 53 | set-option -g base-index 1 #窗口的初始序号;默认为0,这里设置为1 54 | 55 | set-window-option -g pane-base-index 1 # panes index start at 1, setw means set-window-option 56 | set-window-option -g other-pane-height 25 57 | set-window-option -g other-pane-width 80 58 | 59 | # [prefix-c] 创建新窗口 60 | bind-key c new-window 61 | # [prefix-数字] 切换窗口 62 | # [prefix-p] 切换窗口 63 | 64 | # [prefix-t/T] 切换窗口 65 | bind-key t next-window 66 | bind-key T previous-window 67 | # bind-key space next-window 68 | # bind-key bspace previous-window 69 | 70 | # [prefix-Ctrl-o] 窗口轮转 71 | bind-key C-o rotate-window 72 | 73 | 74 | # -------------------------------- window end -------------------------------- 75 | 76 | # -------------------------------- pane begin -------------------------------- 77 | # use vim-like keys for splits and windows 78 | # v / s 竖直、水平分割window为pane 79 | unbind '"' 80 | unbind % 81 | # 窗口切割 split windows like vim. - Note: vim's definition of a horizontal/vertical split is reversed from tmux's 82 | # [prefix-v] / [prefix-s] 垂直/水平分割窗口 83 | # bind-key v split-window -h 84 | # bind-key s split-window -v 85 | 86 | # key bindings for horizontal and vertical panes 87 | # 键 [\|] 和 [_-] 少敲一个shift键 88 | bind-key \ split-window -h 89 | bind-key - split-window -v 90 | 91 | # 窗口间切换 92 | # [prefix-hjkl] pane之间移动 93 | unbind-key h 94 | bind-key h select-pane -L 95 | unbind-key j 96 | bind-key j select-pane -D 97 | unbind-key k 98 | bind-key k select-pane -U 99 | unbind-key l 100 | bind-key l select-pane -R 101 | # smart pane switching with awareness of vim splits 102 | # [Ctrl-hjkl] pane之间移动 103 | bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-h) || tmux select-pane -L" 104 | bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-j) || tmux select-pane -D" 105 | bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-k) || tmux select-pane -U" 106 | bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-l) || tmux select-pane -R" 107 | # [Ctrl-l] 左右两个切 [Ctrl-\] 最近的两个切换 108 | bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys 'C-\\') || tmux select-pane -l" 109 | bind C-l send-keys 'C-l' 110 | 111 | # [prefix-q] 展示窗口数字并选择跳转 112 | bind-key q display-panes 113 | # bind-key a last-pane # 绑什么好? 114 | 115 | # 窗口大小调整 116 | # resize panes using PREFIX H, J, K, L 117 | bind H resize-pane -L 5 118 | bind J resize-pane -D 5 119 | bind K resize-pane -U 5 120 | bind L resize-pane -R 5 121 | 122 | # layout 123 | # [prefix-space] 124 | # bind-key + select-layout main-horizontal 125 | # bind-key = select-layout main-vertical 126 | 127 | # -------------------------------- pane end -------------------------------- 128 | 129 | # -------------------------------- move/copy/paste begin -------------------------------- 130 | # use vi mode 131 | # vi is good 把 Tmux 设为 vi 模式,使其与 Vim 的操作更加接近 132 | setw -g mode-keys vi 133 | 134 | # [ 进入复制,space键开始选择问题 方向键移动, / 回车复制 / ] 黏贴 135 | bind-key [ copy-mode 136 | bind-key ] paste-buffer 137 | 138 | # Copy and paste like in vim 139 | # p 换成paste 140 | unbind p 141 | bind p paste-buffer 142 | 143 | 144 | # the following vi-copy bindings match my vim settings 145 | # see https://github.com/gpakosz/.vim.git 146 | # Setup 'v' to begin selection as in Vim 147 | bind-key -T copy-mode-vi v send-keys -X begin-selection 148 | bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle 149 | 150 | bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" 151 | bind-key -T copy-mode-vi Escape send-keys -X cancel 152 | bind-key -T copy-mode-vi H send-keys -X start-of-line 153 | bind-key -T copy-mode-vi L send-keys -X end-of-line 154 | 155 | # Update default binding of `Enter` to also use copy-pipe 156 | unbind-key -T copy-mode-vi Enter 157 | bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" 158 | # bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" 159 | bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" 160 | 161 | # for osx 162 | # Enable native Mac OS X copy/paste 对于mac用户,可以复制到系统剪贴板 163 | set-option -g default-command "/bin/bash -c 'which reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace $SHELL -l || exec $SHELL -l'" 164 | # -------------------------------- move/copy/paste end -------------------------------- 165 | 166 | # -------------------------------- mouse begin -------------------------------- 167 | # mouse behavior 168 | # Using set -gq instead of set -g will silence the unknown option error, while still setting it on old versions of tmux 169 | setw -gq mode-mouse on 170 | set -gq mouse-select-pane on 171 | set -gq mouse-resize-pane on 172 | set -gq mouse-select-window on 173 | # -------------------------------- mouse end -------------------------------- 174 | 175 | # -------------------------------- status line begin -------------------------------- 176 | # 颜色 177 | # set-option -g status-bg black 178 | # set-option -g status-fg white 179 | 180 | set -g status-bg '#4e4e4e' 181 | set -g status-fg '#bbbbbb' 182 | set -g status-left-fg '#bbbbbb' 183 | set -g status-left-bg '#4e4e4e' 184 | set -g status-right-fg '#bbbbbb' 185 | set -g status-right-bg '#4e4e4e' 186 | 187 | set -g status-left-length 90 188 | set -g status-right-length 60 189 | 190 | # 对齐方式 191 | set-option -g status-justify centre 192 | 193 | # 左下角 194 | # set-option -g status-left '#[bg=black,fg=green][#[fg=cyan]#S#[fg=green]]' 195 | set-option -g status-left "S-#S:W-#I:P-#P" 196 | 197 | # 窗口列表 198 | setw -g automatic-rename on 199 | # set-window-option -g window-status-current-fg magenta 200 | set-window-option -g window-status-format '#[dim]#I:#[dim]#W#[fg=grey,dim]' 201 | set-window-option -g window-status-current-format '[#[fg=white,bold]#I#[fg=white,bold]:#[fg=white,bold]#W#[fg=dim]]' 202 | 203 | 204 | # 右下角 205 | set -g status-right '#[fg=green][#[fg=white]%m-%d %H:%M#[fg=green]]' 206 | 207 | 208 | # -------------------------------- status line end -------------------------------- 209 | # -------------------------------- color begin -------------------------------- 210 | 211 | # pane border colors 212 | set-option -g pane-active-border-fg '#55ff55' 213 | set-option -g pane-border-fg '#555555' 214 | # set -g pane-border-fg colour245 215 | # set -g pane-active-border-fg colour39 216 | 217 | # -------------------------------- color end -------------------------------- 218 | 219 | #--------------------------- base config end ------------------------------- 220 | 221 | --------------------------------------------------------------------------------