Emacsと同じキーを使ってtmuxウィンドウを分割しますか?

Emacsと同じキーを使ってtmuxウィンドウを分割しますか?

C-x 2Emacsでは、C-x 3(1つは別のものの上に)または(1つは別のものの横に)を使用してウィンドウを分割できます。

同じキーバインディングをどのように取得できますかtmux

また、ウィンドウが分割されると、emacsはウィンドウを循環させることができますC-x otmux同じキーを使用するように設定できますか?

ベストアンサー1

これで夢が叶います。 https://github.com/tmux/tmux/issues/2904

私のユースケースは次のとおりです

  • tmuxウィンドウにフォーカスがあるがemacsclientにない場合(たとえば、端末プロンプトで)、[Cx o]を使用して同じウィンドウの次のtmuxウィンドウに切り替えます。
  • tmuxウィンドウにフォーカスとemacsclientがある場合集中する同様に、emacsに[Cx o]を処理させるようにしてください。

tmux.conf:

is_emacs='echo "#{pane_current_command}" | grep -iqE "emacs"'
bind -Temacs-keys o if-shell "$is_emacs" "send C-x; send" "select-pane -t :.+"
bind -Temacs-keys Any { send C-x; send }
bind -Troot C-x switch-client -Temacs-keys

初期化.el:

;;; Tmux integration (See tmux.conf for details).
(defun id/other-window ()
  "Switch to the next window if opened, otherwise select next tmux pane."
  (interactive)
  (if (eq (next-window) (get-buffer-window))
      (call-process "tmux" nil nil nil "select-pane" "-t" ":.+")
    (other-window 1)))

(global-set-key [remap other-window] #'id/other-window)

おすすめ記事