mirror of
https://github.com/tmux-plugins/tmux-logging.git
synced 2026-09-10 07:16:28 -04:00
Merge 61e471ea71 into b5c5f7b9bc
This commit is contained in:
commit
efba826858
12
README.md
12
README.md
|
|
@ -43,7 +43,17 @@ you need to log/save all the work.
|
|||
* File path: `$HOME` (user home dir)
|
||||
* Example file: `tmux-history-my-session-0-1-20140527T165614.log`
|
||||
|
||||
**NOTE**: this functionality depends on the value of `history-limit` - the number
|
||||
### 4. Save complete history and continue logging to same file
|
||||
|
||||
Save complete pane history to a file then continue logging to it. Convenient if you retroactively remember you need to log/save all the work, including what follows.
|
||||
|
||||
* Key binding: `prefix + ctrl + P`
|
||||
* File name format: `tmux-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log`
|
||||
* File path: `$HOME` (user home dir)
|
||||
* Example file: `~/tmux-my-session-0-1-20140527T165614.log`
|
||||
|
||||
|
||||
**NOTE**: the last 2 features functionality depends on the value of `history-limit` - the number
|
||||
of lines Tmux keeps in the scrollback buffer. Only what Tmux kept will also be saved,
|
||||
to a file.
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ main() {
|
|||
tmux bind-key "$pane_screen_capture_key" run-shell "$CURRENT_DIR/scripts/screen_capture.sh"
|
||||
tmux bind-key "$save_complete_history_key" run-shell "$CURRENT_DIR/scripts/save_complete_history.sh"
|
||||
tmux bind-key "$clear_history_key" run-shell "$CURRENT_DIR/scripts/clear_history.sh"
|
||||
tmux bind-key "$snapshot_and_log_key" run-shell "$CURRENT_DIR/scripts/snapshot_and_log.sh"
|
||||
}
|
||||
|
||||
main
|
||||
|
|
|
|||
19
scripts/snapshot_and_log.sh
Executable file
19
scripts/snapshot_and_log.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/variables.sh"
|
||||
source "$CURRENT_DIR/shared.sh"
|
||||
|
||||
main() {
|
||||
if supported_tmux_version_ok; then
|
||||
local file=$(expand_tmux_format_path "${logging_full_filename}")
|
||||
local history_limit="$(tmux display-message -p -F "#{history_limit}")"
|
||||
tmux capture-pane -J -S "-${history_limit}" -p > "${file}"
|
||||
remove_empty_lines_from_end_of_file "${file}"
|
||||
"$CURRENT_DIR/start_logging.sh" "${file}"
|
||||
|
||||
display_message "History saved and logging started to ${file}"
|
||||
fi
|
||||
}
|
||||
main
|
||||
|
|
@ -3,6 +3,17 @@
|
|||
# path to log file - global variable
|
||||
FILE="$1"
|
||||
|
||||
# If called directly, read context and enable logging
|
||||
if [ ! "${FILE}" ] ; then
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/variables.sh"
|
||||
source "$CURRENT_DIR/shared.sh"
|
||||
file=$(expand_tmux_format_path "${logging_full_filename}")
|
||||
display_message "Started logging to ${logging_full_filename}"
|
||||
|
||||
fi
|
||||
|
||||
ansifilter_installed() {
|
||||
type ansifilter >/dev/null 2>&1 || return 1
|
||||
}
|
||||
|
|
@ -18,12 +29,14 @@ pipe_pane_ansifilter() {
|
|||
pipe_pane_sed_osx() {
|
||||
# Warning, very complex regex ahead.
|
||||
# Some characters below might not be visible from github web view.
|
||||
local ansi_codes_osx="(\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]|
|]0;[^]+|[[:space:]]+$)"
|
||||
local ansi_codes_osx="(\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]|
|
||||
|]0;[^]+|[[:space:]]+$)"
|
||||
tmux pipe-pane "exec cat - | sed -E \"s/$ansi_codes_osx//g\" >> $FILE"
|
||||
}
|
||||
|
||||
pipe_pane_sed() {
|
||||
local ansi_codes="(\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]|
)"
|
||||
local ansi_codes="(\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]|
|
||||
)"
|
||||
tmux pipe-pane "exec cat - | sed -r 's/$ansi_codes//g' >> $FILE"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ default_save_complete_history_key="M-P" # Alt-Shift-p
|
|||
save_complete_history_key=$(tmux show-option -gqv "@save-complete-history-key")
|
||||
save_complete_history_key=${save_complete_history_key:-$default_save_complete_history_key}
|
||||
|
||||
default_snapshot_and_log_key="C-P" # Control-Shift-p
|
||||
snapshot_and_log_key=$(tmux show-option -gqv "@snapshot_and_log")
|
||||
snapshot_and_log_key=${snapshot_and_log_key:-$default_snapshot_and_log_key}
|
||||
|
||||
default_clear_history_key="M-c" # Alt-c
|
||||
clear_history_key=$(tmux show-option -gqv "@clear-history-key")
|
||||
clear_history_key=${clear_history_key:-$default_clear_history_key}
|
||||
|
|
|
|||
Loading…
Reference in a new issue