Using fzf to select the panes of tmux, like selecting buffer by using fzf in vim.
It's a alternative for choose-tree
which is a native command of tmux.
- Show resources of every pane's process
- Combine multiple panes into a window
- Order by Most Recently Used (MRU) panes
- Join the current pane and the target pane
- Swap the current pane and the target pane
- Kill the target pane
- Display the path of the current buffer of vim dynamically in fzf field of cmd
- Display the current path of shell in fzf field of cmd
- Select last pane across windows and sessions
- Install
fzf-panes.tmux
under the path where you like. - Put these code inside your
.tmux.conf
.
set -s focus-events on
# replace ~/.local/bin/fzf-panes.tmux with fzf-panes.tmux under your PATH
if-shell '[ -f ~/.local/bin/fzf-panes.tmux ]' {
# if you want to exclude specified session, please set @fzf_panes_ex_session_pat
# for example, value equal to '^(floating)$', will exclude panes in session named 'floating':
# set -g '@fzf_panes_ex_session_pat' '^(floating)$'
set-hook -g pane-focus-in[10] \
"run -b 'bash ~/.local/bin/fzf-panes.tmux update_mru_pane_ids'"
bind w run -b 'bash ~/.local/bin/fzf-panes.tmux new_window'
bind \; run -b 'bash ~/.local/bin/fzf-panes.tmux select_last_pane'
} {
set-hook -ug pane-focus-in[10]
bind w choose-tree -Z
}
- If you want to display the path of the current buffer of vim dynamically in fzf's cmd field, you
should set the vim option
titlestring
like this:
set title
set titlestring=%(%m%)%(%{expand(\"%:~\")}%)
The
ps
command only record startup command of vim, so I use title of vim to replace the argument of vim's cmd inps
.
- Using
prefix+w
to call the script in new window of tmux. - Using
prefix+;
to select last pane across windows and sessions
alt-p
: toggle the preview for detail of the panealt-n
: create new windowctrl-r
: reload the source of fzfctrl-x
: kill the target panectrl-v
: join the current pane and the the target pane verticallyctrl-s
: join the current pane and the the target pane horizontallyctrl-t
: swap the current pane and the target pane