From 18aedaeb55da3bc65583f134797f8e60cc5eb80e Mon Sep 17 00:00:00 2001 From: liuyi Date: Sun, 12 May 2019 23:26:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AE=8C=E5=96=84=20vim=20=E5=88=87?= =?UTF-8?q?=E7=AA=97=E6=94=AF=E6=8C=81=EF=BC=9A=E4=BB=A5=20vi=20=E6=89=93?= =?UTF-8?q?=E5=BC=80=E5=90=8C=E6=A0=B7=E5=8F=AF=E4=BB=A5=E3=80=82=E6=96=B0?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=89=93=E5=BC=80=E6=97=B6=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E5=88=87=E5=88=B0=E5=BD=93=E5=89=8D=E7=9B=AE=E5=BD=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tmux.conf | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tmux.conf b/tmux.conf index 6b15aa4..cd67ec0 100644 --- a/tmux.conf +++ b/tmux.conf @@ -57,13 +57,14 @@ set-window-option -g other-pane-height 25 set-window-option -g other-pane-width 80 # [prefix-c] 创建新窗口 -bind-key c new-window +bind-key c new-window -c "#{pane_current_path}" # [prefix-数字] 切换窗口 # [prefix-p] 切换窗口 # [prefix-t/T] 切换窗口 bind-key t next-window bind-key T previous-window +bind-key N previous-window # bind-key space next-window # bind-key bspace previous-window @@ -85,8 +86,8 @@ unbind % # key bindings for horizontal and vertical panes # 键 [\|] 和 [_-] 少敲一个shift键 -bind-key \ split-window -h -bind-key - split-window -v +bind-key \ split-window -h -c "#{pane_current_path}" +bind-key - split-window -v -c "#{pane_current_path}" # 窗口间切换 # [prefix-hjkl] pane之间移动 @@ -100,12 +101,12 @@ unbind-key l bind-key l select-pane -R # smart pane switching with awareness of vim splits # [Ctrl-hjkl] pane之间移动 -bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-h) || tmux select-pane -L" -bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-j) || tmux select-pane -D" -bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-k) || tmux select-pane -U" -bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-l) || tmux select-pane -R" +bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-h) || tmux select-pane -L" +bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-j) || tmux select-pane -D" +bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-k) || tmux select-pane -U" +bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-l) || tmux select-pane -R" # [Ctrl-l] 左右两个切 [Ctrl-\] 最近的两个切换 -bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys 'C-\\') || tmux select-pane -l" +bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys 'C-\\') || tmux select-pane -l" bind C-l send-keys 'C-l' # [prefix-q] 展示窗口数字并选择跳转 From 7e9f63b12d6e9c20abcb4ae538105617ef0167e2 Mon Sep 17 00:00:00 2001 From: liuyi Date: Sun, 12 May 2019 23:44:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BC=A0=E6=A0=87?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=9A=84=E9=85=8D=E7=BD=AE=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E9=80=82=E5=BA=94=E6=9B=B4=E9=AB=98=E7=9A=84=20tmux=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit set-option -g mouse on --- tmux.conf | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tmux.conf b/tmux.conf index cd67ec0..cbe12c2 100644 --- a/tmux.conf +++ b/tmux.conf @@ -167,10 +167,13 @@ set-option -g default-command "/bin/bash -c 'which reattach-to-user-namespace >/ # -------------------------------- mouse begin -------------------------------- # mouse behavior # Using set -gq instead of set -g will silence the unknown option error, while still setting it on old versions of tmux -setw -gq mode-mouse on -set -gq mouse-select-pane on -set -gq mouse-resize-pane on -set -gq mouse-select-window on +#setw -gq mode-mouse on +#set -gq mouse-select-pane on +#set -gq mouse-resize-pane on +#set -gq mouse-select-window on + +# luice: after tmux 2.1, the mouse mode changed into: +set-option -g mouse on # -------------------------------- mouse end -------------------------------- # -------------------------------- status line begin -------------------------------- From 17ae7e09355dfdef57de4d8ed2517894be808b0d Mon Sep 17 00:00:00 2001 From: liuyi Date: Mon, 13 May 2019 02:30:30 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Ubuntu=20=E7=B3=BB=E7=BB=9F=E4=B8=8B?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=B8=8E=E7=B3=BB=E7=BB=9F=E5=89=AA=E8=B4=B4?= =?UTF-8?q?=E6=9D=BF=E6=97=A0=E7=BC=9D=E5=AF=B9=E6=8E=A5=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20xclip=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tmux.conf | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tmux.conf b/tmux.conf index cbe12c2..4f83d6c 100644 --- a/tmux.conf +++ b/tmux.conf @@ -23,8 +23,7 @@ set-option -g default-terminal "screen-256color" # use 256 colors set-option -g history-limit 100000 # scrollback buffer n lines set-option -g display-time 5000 # 提示信息的持续时间;设置足够的时间以避免看不清提示,单位为毫秒 set-option -g repeat-time 1000 # 控制台激活后的持续时间;设置合适的时间以避免每次操作都要先激活控制台,单位为毫秒 -set-window-option -g display-panes-time 1500 -set-option -g repeat-time 0 # Allow the arrow key to be used immediately after changing windows +set-window-option -g display-panes-time 3000 set-option -g renumber-windows on # window 0, 1, 2, remove 1, renumber to 0, 1 @@ -92,21 +91,21 @@ bind-key - split-window -v -c "#{pane_current_path}" # 窗口间切换 # [prefix-hjkl] pane之间移动 unbind-key h -bind-key h select-pane -L +bind-key -r h select-pane -L unbind-key j -bind-key j select-pane -D +bind-key -r j select-pane -D unbind-key k -bind-key k select-pane -U +bind-key -r k select-pane -U unbind-key l -bind-key l select-pane -R +bind-key -r l select-pane -R # smart pane switching with awareness of vim splits # [Ctrl-hjkl] pane之间移动 -bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-h) || tmux select-pane -L" -bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-j) || tmux select-pane -D" -bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-k) || tmux select-pane -U" -bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-l) || tmux select-pane -R" +bind -r -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-h) || tmux select-pane -L" +bind -r -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-j) || tmux select-pane -D" +bind -r -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-k) || tmux select-pane -U" +bind -r -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-l) || tmux select-pane -R" # [Ctrl-l] 左右两个切 [Ctrl-\] 最近的两个切换 -bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys 'C-\\') || tmux select-pane -l" +bind -r -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys 'C-\\') || tmux select-pane -l" bind C-l send-keys 'C-l' # [prefix-q] 展示窗口数字并选择跳转 @@ -115,10 +114,10 @@ bind-key q display-panes # 窗口大小调整 # resize panes using PREFIX H, J, K, L -bind H resize-pane -L 5 -bind J resize-pane -D 5 -bind K resize-pane -U 5 -bind L resize-pane -R 5 +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 # layout # [prefix-space] @@ -134,12 +133,13 @@ setw -g mode-keys vi # [ 进入复制,space键开始选择问题 方向键移动, / 回车复制 / ] 黏贴 bind-key [ copy-mode -bind-key ] paste-buffer +bind-key ] run " tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer" # Copy and paste like in vim # p 换成paste unbind p -bind p paste-buffer +bind p run " tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer" +bind -n C-v run " tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer" # the following vi-copy bindings match my vim settings @@ -148,16 +148,16 @@ bind p paste-buffer bind-key -T copy-mode-vi v send-keys -X begin-selection bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle -bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" +bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel " tmux save-buffer - | xclip -i -sel clipboard" bind-key -T copy-mode-vi Escape send-keys -X cancel bind-key -T copy-mode-vi H send-keys -X start-of-line bind-key -T copy-mode-vi L send-keys -X end-of-line # Update default binding of `Enter` to also use copy-pipe unbind-key -T copy-mode-vi Enter -bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" +bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel " tmux save-buffer - | xclip -i -sel clipboard" # bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" -bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel " tmux save-buffer - | xclip -i -sel clipboard" # for osx # Enable native Mac OS X copy/paste 对于mac用户,可以复制到系统剪贴板