Hi there, Tmux enthusiasts! Ever been lost in a sea of old commands while scrolling back in your Tmux session? Fret not! There is indeed a way to declutter and start with a clean slate. Today, I’m going to walk you through how to clear history in Tmux. Just like you, I’ve felt the need to have a clean workspace, and Tmux offers just the right command to do that. So, let’s dive into the world of Tmux and learn how to keep our sessions neat and tidy!
If you are new to Tmux, then learn the basics of Tmux, if not, Let’s get started!
Let’s consider a case where you have a lot of history in tmux panes with which has to be cleared. We need to send a command to all the panes in a window to clear history in all your panes.
Clear History of active pane in Tmux
You can clear history of your tmux pane by running the following commands inside the pane, Here, let’s assume that your <prefix>
is Ctrl-B
, which is the default prefix.
Ctrl-B
:
clear-history
In case you are in the in the command line, you can run the following command in your shell-
tmux clear-history
You can also bind it to a keyboard shortcut, which makes clearing history easier, set this in your ~/.tmux.conf
–
bind -n C-k clear-history
You have to reload changes in tmux config tmux.conf
so that it reflects-
tmux source-file ~/.tmux.conf
So, now just do the following shortcut combination to clear history-
Ctrl-B
Ctrl-K
Clear History of all panes in a Tmux Window
You can use <prefix> :setw synchronize-panes on
to set the ability to send commands to all panes. All panes in the given window are all now synchronized to receive the same command.
Here, let’s assume that your <prefix>
is Ctrl-B
, which is the default prefix.
Let’s take an example, let’s say you want to clear history across all panes in a window. You can do the follow set of commands-
Ctrl-B
:
setw synchronize-panes on
clear-history
To disable the synchronize-panes state, you can use the following command-
Ctrl-B
:
setw synchronize-panes off
You can also reset a tmux config in case you feel some of your tmux plugins are not working as expected and start with a clean config.
And there you have it, a quick and easy way to clear history in Tmux! Now you can have a fresh start whenever your session gets too cluttered. Remember, having a clean and manageable terminal can save you a lot of time and effort in the long run. So don’t shy away from using this clear history feature. Keep exploring, keep learning, and until next time, happy Tmuxing!
You can also check out the complete tmux cheatsheet of keyboard shortcuts and mouse shortcuts.