在 emacs 和 vim 中使用 tmux

在 emacs 和 vim 中使用 tmux

tmux 的最佳預設鍵綁定是什麼? Ctrl-b 可以,但與 bash shell 和 emacs 有點衝突。

答案1

我在相關貼文中找到了一個很好的答案:screen 或 tmux 衝突最少的前綴/轉義序列是什麼?

我用的是 Ctrl-\。下面是我的 ~/.tmux-conf:

set-window-option -g mode-keys vi
set-window-option -g window-status-current-bg blue
set-window-option -g automatic-rename on
set-option -g status-keys vi
set-option -g history-limit 100000
set-option -g base-index 1
set-option -s escape-time 0
setw -g mode-mouse on
set-option -g mouse-select-pane on

# We won't worry about sending C-\ to any programs
# bind-key C-\ send-prefix

# hit C-\ twice to go to last window
bind-key C-\ last-window
bind-key b set-option status

bind-key / command-prompt "split-window 'exec man %%'"
# vim's definition of a horizontal/vertical split is reversed from tmux's
bind s split-window -v
bind v split-window -h

# move around panes with hjkl, as one would in vim after pressing ctrl-w
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# resize panes like vim
bind < resize-pane -L 10
bind > resize-pane -R 10
bind - resize-pane -D 10
bind + resize-pane -U 10

# C-b is not acceptable, due to emacs, bash, and vim
unbind-key C-b
set-option -g prefix C-\

答案2

我強烈喜歡C-],它與 vi 綁定不衝突,但與abort-recursive-editEmacs 中的預設綁定衝突。我很少使用它,而且在非常糟糕的情況下,輸入兩次也沒什麼大不了的。

答案3

我已經使用 Ctrl-/ 一段時間了,至少在 vim/bash 中沒有發現與任何東西衝突。我不使用 emacs,所以我不知道它是否與其中重要的內容衝突。

還有一個小註釋,我相信我必須將其綁定到 C-_ 才能使其正常工作,因為這是它發送的實際密鑰。

答案4

我用C-\。請注意,您需要使用單引號對其進行轉義:

unbind-key C-b
set-option -g prefix C-'\'

相關內容