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
9a6e4a1a
Unverified
Commit
9a6e4a1a
authored
Aug 29, 2014
by
Bruno Sutic
Browse files
Make pane restorations idempotent
parent
bd13c9ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
9a6e4a1a
...
...
@@ -3,6 +3,8 @@
### master
-
bugfix: when top is running the pane
`$PWD`
can't be saved. This was causing
issues during the restore and is now fixed.
-
restoring sessions multiple times messes up the whole environment - new panes
are all around. This is now fixed - pane restorations are now idempotent.
### v0.2.0, 2014-08-29
-
bugfix: with vim 'session' strategy, if the session file does not exist - make
...
...
scripts/session_restorer.sh
View file @
9a6e4a1a
...
...
@@ -22,6 +22,14 @@ check_saved_session_exists() {
fi
}
pane_exists
()
{
local
session_name
=
"
$1
"
local
window_number
=
"
$2
"
local
pane_index
=
"
$3
"
tmux list-panes
-t
"
${
session_name
}
:
${
window_number
}
"
-F
"#{pane_index}"
2>/dev/null |
\g
rep
-q
"^
$pane_index
$"
}
window_exists
()
{
local
session_name
=
"
$1
"
local
window_number
=
"
$2
"
...
...
@@ -78,7 +86,9 @@ restore_pane() {
dir
=
"
$(
remove_first_char
"
$dir
"
)
"
window_name
=
"
$(
remove_first_char
"
$window_name
"
)
"
pane_full_command
=
"
$(
remove_first_char
"
$pane_full_command
"
)
"
if
window_exists
"
$session_name
"
"
$window_number
"
;
then
if
pane_exists
"
$session_name
"
"
$window_number
"
"
$pane_index
"
;
then
true
# pane exists, no need to create it!
elif
window_exists
"
$session_name
"
"
$window_number
"
;
then
new_pane
"
$session_name
"
"
$window_number
"
"
$window_name
"
"
$dir
"
elif
session_exists
"
$session_name
"
;
then
new_window
"
$session_name
"
"
$window_number
"
"
$window_name
"
"
$dir
"
...
...
@@ -97,7 +107,7 @@ restore_state() {
done
}
restore_all_
session
s
()
{
restore_all_
pane
s
()
{
while
read
line
;
do
if
is_line_type
"pane"
"
$line
"
;
then
restore_pane
"
$line
"
...
...
@@ -151,7 +161,7 @@ restore_active_and_alternate_sessions() {
main
()
{
if
supported_tmux_version_ok
&&
check_saved_session_exists
;
then
start_spinner
restore_all_
session
s
restore_all_
pane
s
restore_all_pane_processes
restore_pane_layout_for_each_window
>
/dev/null 2>&1
# below functions restore exact cursor positions
...
...
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