Capture pane contents feature, small refactor

This commit is contained in:
Bruno Sutic 2015-05-09 12:22:48 +02:00
parent 00008e7f40
commit fee40e2121
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
2 changed files with 8 additions and 3 deletions

View File

@ -112,7 +112,10 @@ pane_full_command() {
capture_pane_contents() { capture_pane_contents() {
local pane_id="$1" local pane_id="$1"
local start_line="-$2" local start_line="-$2"
[[ "$(get_tmux_option "$pane_contents_area_option" "full")" == "visible" ]] && start_line="0" local pane_contents_area="$3"
if [ "$pane_contents_area" = "visible" ]; then
start_line="0"
fi
tmux capture-pane -epJ -S "$start_line" -t "$pane_id" > "$(resurrect_pane_file "$pane_id")" tmux capture-pane -epJ -S "$start_line" -t "$pane_id" > "$(resurrect_pane_file "$pane_id")"
} }
@ -210,9 +213,10 @@ dump_state() {
} }
dump_pane_contents() { dump_pane_contents() {
local pane_contents_area="$(get_tmux_option "$pane_contents_area_option" "$default_pane_contents_area")"
paste -d"$d" <(dump_panes) <(dump_panes_raw "#{history_size}") | paste -d"$d" <(dump_panes) <(dump_panes_raw "#{history_size}") |
while IFS=$d read line_type session_name window_number window_name window_active window_flags pane_index dir pane_active pane_command full_command history_size; do while IFS=$d read line_type session_name window_number window_name window_active window_flags pane_index dir pane_active pane_command full_command history_size; do
capture_pane_contents "$session_name:$window_number.$pane_index" "$history_size" capture_pane_contents "$session_name:$window_number.$pane_index" "$history_size" "$pane_contents_area"
done done
} }

View File

@ -31,10 +31,11 @@ default_save_command_strategy="ps"
# Pane contents capture options. # Pane contents capture options.
# @resurrect-pane-contents-area option can be: # @resurrect-pane-contents-area option can be:
# 'visible' - capture only the visible pane area (default) # 'visible' - capture only the visible pane area
# 'full' - capture the full pane contents # 'full' - capture the full pane contents
pane_contents_option="@resurrect-capture-pane-contents" pane_contents_option="@resurrect-capture-pane-contents"
pane_contents_area_option="@resurrect-pane-contents-area" pane_contents_area_option="@resurrect-pane-contents-area"
default_pane_contents_area="full"
bash_history_option="@resurrect-save-bash-history" bash_history_option="@resurrect-save-bash-history"