Implement pane content files compression

pull/104/head
Bruno Sutic 2015-07-08 18:45:43 +02:00
parent a750628a44
commit a47236d247
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
4 changed files with 30 additions and 0 deletions

View File

@ -13,6 +13,7 @@
- do not save pane contents if pane is empty (only for 'save pane contents'
feature)
- "save pane contents" feature saves files to a separate directory
- archive and compress pane contents file
### v2.4.0, 2015-02-23
- add "tmux-test"

View File

@ -71,6 +71,23 @@ is_session_grouped() {
[[ "$GROUPED_SESSIONS" == *"${d}${session_name}${d}"* ]]
}
# pane content file helpers
pane_contents_create_archive() {
tar czf "$(pane_contents_archive_file)" -C "$(resurrect_dir)" ./pane_contents/
}
pane_content_files_restore_from_archive() {
local archive_file="$(pane_contents_archive_file)"
if [ -f "$archive_file" ]; then
tar xzf "$archive_file" -C "$(resurrect_dir)"
fi
}
pane_content_files_cleanup() {
rm "$(pane_contents_dir)"/*
}
# path helpers
resurrect_dir() {
@ -101,6 +118,10 @@ pane_contents_file_exists() {
[ -f "$(pane_contents_file "$pane_id")" ]
}
pane_contents_archive_file() {
echo "$(resurrect_dir)/pane_contents.tar.gz"
}
resurrect_history_file() {
local pane_id="$1"
echo "$(resurrect_dir)/bash_history-${pane_id}"

View File

@ -250,11 +250,17 @@ detect_if_restoring_pane_contents() {
restore_all_panes() {
detect_if_restoring_from_scratch # sets a global variable
detect_if_restoring_pane_contents # sets a global variable
if is_restoring_pane_contents; then
pane_content_files_restore_from_archive
fi
while read line; do
if is_line_type "pane" "$line"; then
restore_pane "$line"
fi
done < $(last_resurrect_file)
if is_restoring_pane_contents; then
pane_content_files_cleanup
fi
}
restore_pane_layout_for_each_window() {

View File

@ -261,6 +261,8 @@ save_all() {
if capture_pane_contents_option_on; then
mkdir -p "$(pane_contents_dir)"
dump_pane_contents
pane_contents_create_archive
pane_content_files_cleanup
fi
if save_bash_history_option_on; then
dump_bash_history