Unverified Commit a47236d2 authored by Bruno Sutic's avatar Bruno Sutic
Browse files

Implement pane content files compression

parent a750628a
......@@ -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"
......
......@@ -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}"
......
......@@ -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() {
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment