Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christian Salzmann-Jaeckel
tmux-resurrect
Commits
b7a4ee2a
Unverified
Commit
b7a4ee2a
authored
May 30, 2017
by
Bruno Sutic
Browse files
Pane contents save and restore in separate dirs
parent
ba59a2b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
scripts/helpers.sh
View file @
b7a4ee2a
...
...
@@ -78,22 +78,19 @@ is_session_grouped() {
# pane content file helpers
pane_contents_create_archive
()
{
tar
cf -
-C
"
$(
resurrect_dir
)
"
./pane_contents/ |
tar
cf -
-C
"
$(
resurrect_dir
)
/save/
"
./pane_contents/ |
gzip
>
"
$(
pane_contents_archive_file
)
"
}
pane_content_files_restore_from_archive
()
{
local
archive_file
=
"
$(
pane_contents_archive_file
)
"
if
[
-f
"
$archive_file
"
]
;
then
mkdir
-p
"
$(
pane_contents_dir
"restore"
)
"
gzip
-d
<
"
$archive_file
"
|
tar
xf -
-C
"
$(
resurrect_dir
)
"
tar
xf -
-C
"
$(
resurrect_dir
)
/restore/
"
fi
}
pane_content_files_cleanup
()
{
rm
"
$(
pane_contents_dir
)
"
/
*
}
# path helpers
resurrect_dir
()
{
...
...
@@ -111,17 +108,18 @@ last_resurrect_file() {
}
pane_contents_dir
()
{
echo
"
$(
resurrect_dir
)
/pane_contents/"
echo
"
$(
resurrect_dir
)
/
$1
/
pane_contents/"
}
pane_contents_file
()
{
local
pane_id
=
"
$1
"
echo
"
$(
pane_contents_dir
)
/pane-
${
pane_id
}
"
local
save_or_restore
=
"
$1
"
local
pane_id
=
"
$2
"
echo
"
$(
pane_contents_dir
"
$save_or_restore
"
)
/pane-
${
pane_id
}
"
}
pane_contents_file_exists
()
{
local
pane_id
=
"
$1
"
[
-f
"
$(
pane_contents_file
"
$pane_id
"
)
"
]
[
-f
"
$(
pane_contents_file
"restore"
"
$pane_id
"
)
"
]
}
pane_contents_archive_file
()
{
...
...
scripts/restore.sh
View file @
b7a4ee2a
...
...
@@ -108,7 +108,7 @@ tmux_default_command() {
}
pane_creation_command
()
{
echo
"cat '
$(
pane_contents_file
"
${
1
}
:
${
2
}
.
${
3
}
"
)
'; exec
$(
tmux_default_command
)
"
echo
"cat '
$(
pane_contents_file
"restore"
"
${
1
}
:
${
2
}
.
${
3
}
"
)
'; exec
$(
tmux_default_command
)
"
}
new_window
()
{
...
...
@@ -259,7 +259,7 @@ restore_all_panes() {
fi
done
<
$(
last_resurrect_file
)
if
is_restoring_pane_contents
;
then
pane_content
_files_cleanup
rm
"
$(
pane_content
s_dir
"restore"
)
"
/
*
fi
}
...
...
scripts/save.sh
View file @
b7a4ee2a
...
...
@@ -138,7 +138,7 @@ capture_pane_contents() {
start_line
=
"0"
fi
# the printf hack below removes *trailing* empty lines
printf
'%s\n'
"
$(
tmux capture-pane
-epJ
-S
"
$start_line
"
-t
"
$pane_id
"
)
"
>
"
$(
pane_contents_file
"
$pane_id
"
)
"
printf
'%s\n'
"
$(
tmux capture-pane
-epJ
-S
"
$start_line
"
-t
"
$pane_id
"
)
"
>
"
$(
pane_contents_file
"save"
"
$pane_id
"
)
"
fi
}
...
...
@@ -266,10 +266,10 @@ save_all() {
rm
"
$resurrect_file_path
"
fi
if
capture_pane_contents_option_on
;
then
mkdir
-p
"
$(
pane_contents_dir
)
"
mkdir
-p
"
$(
pane_contents_dir
"save"
)
"
dump_pane_contents
pane_contents_create_archive
pane_content
_files_cleanup
rm
"
$(
pane_content
s_dir
"save"
)
"
/
*
fi
if
save_bash_history_option_on
;
then
dump_bash_history
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment