Features:
- Enables logging of all output in the current pane
After you start logging, everything that's typed and all the output will be saved to a file. Convenient for keeping track of your work. - Enables "screen capture" of the current pane
All the text visible in the current pane is saved to a file. Like a screenshot, but textual. - Enables saving a complete history of the current pane
Everything that has been typed and all the output since the creation of the current pane can be saved to a file. - Clear pane history with
prefix + alt + c
Tested and working on Linux, OSX and Cygwin.
Key binding: prefix + shift + p
File path: $HOME
(user home dir)
File name format:
tmux-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log
# Example file:
# tmux-my-session-0-1-20140527T165614.log
Toggles (start/stop) logging in the current pane.
This feature improves the default pipe-pane
logging mechanism by stripping
ANSI codes. This is how the plain pipe-pane
log output looks like if you're
using terminal with coloring:
Garbled characters are called ANSI codes. They enable colors in terminal, but are just making 'noise' in the textual log output.
A user will probably want to filter ANSI codes out of the log. Here's the same log as above when this plugin is used:
Key binding: prefix + alt + p
File path: $HOME
(user home dir)
File name format:
tmux-screen-capture-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log
# Example file:
# tmux-screen-capture-my-session-0-1-20140527T165614.log
Visible text in the current pane is saved to a file. Equivalent of a "texual screenshot".
Key binding: prefix + alt + shift + p
File path: $HOME
(user home dir)
File name format:
tmux-history-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log
# Example file:
# tmux-history-my-session-0-1-20140527T165614.log
Saves complete pane history to a file. Convenient if you retroactively remember you need to log/save all the work.
NOTE: this functionality depends on the value of history-limit
- it
determines the number of lines Tmux keeps in the scrollback buffer. Everything
Tmux kept will also be saved to a file.
With modern computers it is ok to set this option to a high number:
# in .tmux.conf
set -g history-limit 50000
Key binding: prefix + alt + c
This is just a convenience key binding.
Installation with Tmux Plugin Manager (recommended)
Add plugin to the list of TPM plugins in .tmux.conf
:
set -g @plugin 'tmux-plugins/tmux-logging'
Hit prefix + I
to fetch the plugin and source it.
You should now have all tmux-logging
key bindings defined.
Clone the repo:
$ git clone https://github.com/tmux-plugins/tmux-logging ~/clone/path
Add this line to the bottom of .tmux.conf
:
run-shell ~/clone/path/logging.tmux
Reload TMUX environment:
# type this in terminal
$ tmux source-file ~/.tmux.conf
You should now have all tmux-logging
key bindings defined.
ansifilter is a program specialized for removing (or working with) ANSI codes.
If you're on OSX, it is recommeneded to install ansifilter
:
$ brew install ansifilter
It helps with removing ANSI codes from the log. If ansifilter
is not present,
ANSI codes are removed with sed
.
You might also find these useful:
- resurrect - restore tmux environment after system restart
- pain control - useful standard bindings for controlling panes
- sessionist - lightweight tmux utils for switching and creating sessions
You might want to follow @brunosutic on twitter if you want to hear about new tmux plugins or feature updates.