DEV Community

Cover image for Easy scrolling with tmux and alacritty
Felix Terkhorn
Felix Terkhorn

Posted on Edited on

Easy scrolling with tmux and alacritty

We want to have a nice experience when scrolling the terminal buffer using both alacritty and tmux on Debian linux.

When we run alacritty and tmux together and there's a lot of text on the screen (say, by invoking tree), we need to hit the following tmux key sequence to scroll back through the terminal history:

Ctrl+B 
[
PageUp
📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung 📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung

This is difficult. Others have asked about this.

We followed the workaround advice given by the author. We enabled mouse mode, and disabled faux scrolling in .tmux.conf:

set -g mouse on
set -ga terminal-overrides ',*256color*:smcup@:rmcup@'
📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung 📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung

In .alacritty.conf, the default scrolling key combination, Shift+PageUp, isn't too bad. We can just leave it commented to use it, but if we want to try our own settings, we can:

key_bindings:
#
# ...snip...
#
- { key: PageUp,   mods: Shift, action: ScrollPageUp,   mode: ~Alt       }
- { key: PageDown, mods: Shift, action: ScrollPageDown, mode: ~Alt       }
- { key: Home,     mods: Shift, action: ScrollToTop,    mode: ~Alt       }
- { key: End,      mods: Shift, action: ScrollToBottom, mode: ~Alt       }
📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung 📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung

Resolution

With the changes to .tmux.conf, we can now start an alacritty terminal, enter tmux, and scroll to our hearts' content, without using a difficult key combination.

🔥 It's FAST! 🔥

We found that scrolling through history with some basic command line apps wasn't negatively impacted.

When we entered tmux + alacritty, and then dumped a lot of text into less, or navigated man bash, we scrolled happily and without interruption.

These instructions probably apply to other terminal emulators, as well.

This is a happy time. 😄

Top comments (3)

📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung
 
mirzalazuardi profile image
Mirzalazuardi • • Edited

nice. thanks a bunch @terkwood ... really need this solution. it works also on WSL2 windows 10

📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung
 
folaht profile image
Folât Pjêrsômêj • • Edited

The mouse scroll works, but

set -ga terminal-overrides ',*256color*:smcup@:rmcup@'
📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung 📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung

does nothing.
And those key binding do not work for man bash or less.

📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung
 
folaht profile image
Folât Pjêrsômêj •

Looks like the key bindings in alacritty need to be left alone, while .tmux.conf needs

set -g mouse on

bind -n PPage copy-mode -eu
bind -T copy-mode Home send-keys -X history-top
bind -T copy-mode End copy-mode -q
📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung 📺 Info Siaran: terkwood/fast scrolling with tmux and alacritty dmn - Jadwal Siaran Langsung