This package is a port of vim-tmux-navigator. It provide integration between emacs windows and tmux panes. Note those tmux panes need not to be created by this package. Tmux panes created in any approach are supported.
Just install tmux-pane
from melpa
.
If you are using TPM, add the following
codes to your ~/.tmux.conf
set -g @plugin 'laishulu/emacs-tmux-pane'
Without TPM, you can manually copy the content of file tmux-pane.tmux
to your
file ~/.tmux.conf
.
A global minor mode tmux-pane-mode
(disabled by default) is provided.
Default key map:
C-k
: UpC-j
: DownC-h
: LeftC-l
: RightC-\
: Last
tmux-pane-open-vertical
: Open a vertical tmux side pane at righttmux-pane-open-horizontal
: Open a vertical tmux side pane at belowtmux-pane-close
: Close the latest tmux side pane if possibletmux-pane-rerun
: Rerun the latest command in the latest tmux panetmux-pane-toggle-vertical
: Open a vertical tmux side pane, or close the latest tmux pane (not necessarily to be the vertical pane).tmux-pane-toggle-horizontal
: Open a horizontal tmux side pane, or close the latest tmux pane (not necessarily to be the horizontal pane).tmux-pane-omni-window-up
: Navigate to the up window of Emacs or tmux.tmux-pane-omni-window-down
: Navigate to the down window of Emacs or tmux.tmux-pane-omni-window-left
: Navigate to the left window of Emacs or tmux.tmux-pane-omni-window-right
: Navigate to the right window of Emacs or tmux.tmux-pane-omni-window-last
: Navigate to the last window of Emacs or tmux.
The following two variable can be customized
tmux-pane-vertical-percent
(Default: 25): Width percentage of the vertical side pane to the whole tmux windowtmux-pane-vertical-percent
(Default: 25): Height percentage of the horizontal side pane to the whole tmux window
tmux-pane-before-leave-hook
(Default: 25): Hook to run before leaving emacs to tmux.tmux-pane-after-leave-hook
(Default: 25): Hook to run after leaving emacs to tmux.
Example configuration for Doom Emacs
(use-package! tmux-pane
:config
(tmux-pane-mode)
(map! :leader
(:prefix ("v" . "tmux pane")
:desc "Open vpane" :nv "o" #'tmux-pane-open-vertical
:desc "Open hpane" :nv "h" #'tmux-pane-open-horizontal
:desc "Open hpane" :nv "s" #'tmux-pane-open-horizontal
:desc "Open vpane" :nv "v" #'tmux-pane-open-vertical
:desc "Close pane" :nv "c" #'tmux-pane-close
:desc "Rerun last command" :nv "r" #'tmux-pane-rerun))
(map! :leader
(:prefix "t"
:desc "vpane" :nv "v" #'tmux-pane-toggle-vertical
:desc "hpane" :nv "h" #'tmux-pane-toggle-horizontal)))