mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-11-21 20:08:48 +00:00
Implement pane content files compression
This commit is contained in:
parent
a750628a44
commit
a47236d247
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user