Right click and swipe left or right in any pane to switch window in that direction or swipe up or down to switch session.
As always any suggestions for improvements are welcome!
When you are at the keyboard obviously a key sequence is both faster and more natural to switch sessions or windows. I use this tool mostly just getting a quick overview when having the terminal on a side screen, in such cases mouse swiping is handy.
The reason I wrote it as a posix script is that since it gets run multiple times in quick sequence, on my iPad running iSH, there is a noticeable performance boost not having to repeatedly start bash scripts.
- Added notifications when drag start was missed and when a cchange can't be made due to only one Window/Session
- Code cleanup
Compatibility
- tmux 3.0
- Modifier-prefixed drag keys (e.g. C-MouseDragPane) need tmux 3.1 — this was broken before then.
With Tmux Plugin Manager (recommended)
Add plugin to the list of TPM plugins in .tmux.conf:
set -g @plugin 'jaclu/tmux-mouse-swipe'Hit <prefix> + I to fetch the plugin and source it.
Clone the repository:
git clone https://github.com/jaclu/tmux-mouse-swipe.git ~/clone/pathAdd this line to the bottom of .tmux.conf:
run-shell ~/clone/path/mouse_swipe.tmuxFrom the terminal, reload TMUX environment:
tmux source-file ~/.tmux.conf| Option | Default | Description |
|---|---|---|
@mouse_swipe_start |
MouseDrag3Pane |
Event starting the swipe |
@mouse_swipe_end |
MouseDragEnd3Pane |
Event ending the swipe |
Once installed, try pressing down right button (plus modifier if defined) and swipe up, down, left or right.
Once you release the button, tmux should switch window after (mostly) horizontal swipe and session after (mostly) vertical swipe.
If you only have one Window or Session, a message will be displayed that the requested action can not be performed.
Since drag isn't registered until you move one character cell, and at least one more cell of movement is needed to detect direction, minimal movement distance is two characters.
If both vertical and horizontal swiping is detected, the axis with the most delta is assumed to be the intended direction. Risk for miss-interpertaion is reduced by making a slightly longer swipe.
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
The best way to send feedback is to file an issue at tmux-mouse-swipe/issues
RaviTharuma - Submitted a patch handling the case when drag start was not detected