Improve log and other small tweaks

This commit is contained in:
Bruno Sutic 2014-05-27 16:43:48 +02:00
parent 8a9f90e40a
commit b8c8f6593b
4 changed files with 34 additions and 27 deletions

View file

@ -1,23 +1,29 @@
# Tmux Logging
Features:
1. Logging of all output in the current pane<br/>
1. Enables logging of all output in the current pane<br/>
After you start logging, everything that's typed and all the output will be
saved to a file.
saved to a file. Convenient for keeping track of your work.
2. Enables "screen capture" of the current pane<br/>
All the text visible in the current pane is saved to a file. Like a
screenshot, but textual.
3. Enables saving a complete history of the current pane<br/>
All that has been typed and all the output since the creation of the current
pane is saved to a file.
Everything that has been typed and all the output since the creation of the
current pane can be saved to a file.
### 1. Logging
Key binding: `prefix + shift + p`<br/>
File path: `$HOME` (user home dir)<br/>
File name template:
tmux-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log
Toggles (start/stop) logging in the current pane.
Logging improves the default `pipe-pane` logging mechanism by stripping ANSI
codes.
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:
@ -35,23 +41,30 @@ log as above when using this plugin:
### 2. "Screen capture"
Key binding: `prefix + alt + p`<br/>
File path: `$HOME` (user home dir)<br/>
File name template:
tmux-screen-capture-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log
Visible text in the current pane is saved to a file. Equivalent of a "texual
screenshot".
File path: `$HOME`<br/>
File name: `$HOME`<br/>
### 3. Capture complete pane history
### 3. Save complete history
Key binding: `prefix + alt + shift + p`<br/>
Saves complete pane scrollback to a file. Convenient if you remember you need
the log of all the work retroactively.
File path: `$HOME` (user home dir)<br/>
File name template:
NOTE: this functionality depends on the value of `history-limit` - it
tmux-history-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.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
that Tmux kept will also be saved to a file.
Tmux kept will also be saved to a file.
With modern computers it is safe to set this option to a high number:
With modern computers it is ok to set this option to a high number:
# in .tmux.conf
set -g history-limit 50000
@ -97,12 +110,6 @@ If you're on OSX, it is recommened to install `ansifilter`:
It helps with removing ANSI codes from the log. If `ansifilter` is not present,
ANSI codes are removed with `sed`.
### Credits
Thanks to Chris Johnsen for providing
[this answer on stackexchange](http://unix.stackexchange.com/a/10259).
This plugin started as an improvement of bindings from that answer.
### License
[MIT](LICENSE.md)

View file

@ -17,10 +17,10 @@ get_filename() {
capture_pane() {
local file="$(get_path)/$(get_filename)"
local capture_scope=$1
if [ $capture_scope == "Scrollback" ]; then
if [ $capture_scope == "History" ]; then
# copying 9M lines back will hopefully fetch the whole scrollback
tmux capture-pane -S -9000000
elif [ $capture_scope == "Screenshot" ]; then
elif [[ $capture_scope == "Screen capture" ]]; then
tmux capture-pane
else
# error

View file

@ -4,7 +4,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Functions defined in capture_pane_helpers are customized via below variables.
default_path="$HOME"
default_name="tmux-screenshot-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log"
default_name="tmux-screen-capture-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log"
path_option="@screenshot_path"
name_option="@screenshot_filename"
@ -13,6 +13,6 @@ source $CURRENT_DIR/shared.sh
source $CURRENT_DIR/capture_pane_helpers.sh
main() {
capture_pane "Screenshot"
capture_pane "Screen capture"
}
main

View file

@ -4,7 +4,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Functions defined in capture_pane_helpers are customized via below variables.
default_path="$HOME"
default_name="tmux-scrollback-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log"
default_name="tmux-history-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log"
path_option="@scrollback_dump_path"
name_option="@scrollback_dump_filename"
@ -13,6 +13,6 @@ source $CURRENT_DIR/shared.sh
source $CURRENT_DIR/capture_pane_helpers.sh
main() {
capture_pane "Scrollback"
capture_pane "History"
}
main