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
c4375bf6
Unverified
Commit
c4375bf6
authored
Feb 10, 2015
by
Bruno Sutic
Browse files
Enable 'full restore' by overwriting a single pane
parent
ddf9c5ef
Changes
4
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
c4375bf6
# Changelog
### master
-
if restore is started when there's only
**1 pane in the whole tmux server**
,
assume the users wants the "full restore" and overrwrite that pane.
### v2.0.0, 2015-02-10
-
add link to the wiki page for "first pane/window issue" to the README as well
...
...
README.md
View file @
c4375bf6
...
...
@@ -51,15 +51,10 @@ This plugin goes to great lengths to save and restore all the details from your
Requirements / dependencies:
`tmux 1.9`
or higher,
`bash`
.
`tmux-resurrect`
is idempotent! It will not try to restore panes or windows that
already exist.
### FAQ
> I have a problem: first pane/window is not restoring!
Check out
[
this wiki page
](
https://github.com/tmux-plugins/tmux-resurrect/wiki/Help:-issues-with-the-first-window
)
for the explanation and problem solution.
already exist.
<br/>
The single exception to this is when tmux is started with only 1 pane in order
to restore previous tmux env. In this case only will this single pane be
overwritten.
### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
...
...
scripts/restore.sh
View file @
c4375bf6
...
...
@@ -16,6 +16,8 @@ d=$'\t'
# is also not restored. That makes the restoration process more idempotent.
EXISTING_PANES_VAR
=
""
RESTORING_FROM_SCRATCH
=
"false"
is_line_type
()
{
local
line_type
=
"
$1
"
local
line
=
"
$2
"
...
...
@@ -56,6 +58,14 @@ is_pane_registered_as_existing() {
[[
"
$EXISTING_PANES_VAR
"
=
~
"
$pane_custom_id
"
]]
}
restore_from_scratch_true
()
{
RESTORING_FROM_SCRATCH
=
"true"
}
is_restoring_from_scratch
()
{
[
"
$RESTORING_FROM_SCRATCH
"
==
"true"
]
}
window_exists
()
{
local
session_name
=
"
$1
"
local
window_number
=
"
$2
"
...
...
@@ -114,9 +124,17 @@ restore_pane() {
window_name
=
"
$(
remove_first_char
"
$window_name
"
)
"
pane_full_command
=
"
$(
remove_first_char
"
$pane_full_command
"
)
"
if
pane_exists
"
$session_name
"
"
$window_number
"
"
$pane_index
"
;
then
# Pane exists, no need to create it!
# Pane existence is registered. Later, it's process also isn't restored.
register_existing_pane
"
$session_name
"
"
$window_number
"
"
$pane_index
"
if
is_restoring_from_scratch
;
then
# overwrite the pane
# happens only for the first pane if it's the only registered pane for the whole tmux server
local
pane_id
=
"
$(
tmux display-message
-p
-F
"#{pane_id}"
-t
"
$session_name
:
$window_number
"
)
"
new_pane
"
$session_name
"
"
$window_number
"
"
$window_name
"
"
$dir
"
tmux kill-pane
-t
"
$pane_id
"
else
# Pane exists, no need to create it!
# Pane existence is registered. Later, its process also won't be restored.
register_existing_pane
"
$session_name
"
"
$window_number
"
"
$pane_index
"
fi
elif
window_exists
"
$session_name
"
"
$window_number
"
;
then
new_pane
"
$session_name
"
"
$window_number
"
"
$window_name
"
"
$dir
"
elif
session_exists
"
$session_name
"
;
then
...
...
@@ -159,9 +177,25 @@ restore_active_and_alternate_windows_for_grouped_sessions() {
done
}
never_ever_overwrite
()
{
local
overwrite_option_value
=
"
$(
get_tmux_option
"
$overwrite_option
"
""
)
"
[
-n
"
$overwrite_option_value
"
]
}
detect_if_restoring_from_scratch
()
{
if
never_ever_overwrite
;
then
return
fi
local
total_number_of_panes
=
"
$(
tmux list-panes
-a
|
wc
-l
|
sed
's/ //g'
)
"
if
[
"
$total_number_of_panes
"
-eq
1
]
;
then
restore_from_scratch_true
fi
}
# functions called from main (ordered)
restore_all_panes
()
{
detect_if_restoring_from_scratch
while
read
line
;
do
if
is_line_type
"pane"
"
$line
"
;
then
restore_pane
"
$line
"
...
...
scripts/variables.sh
View file @
c4375bf6
...
...
@@ -28,3 +28,6 @@ save_command_strategy_option="@resurrect-save-command-strategy"
default_save_command_strategy
=
"ps"
bash_history_option
=
"@resurrect-save-bash-history"
# set to 'on' to ensure panes are never ever overwritten
overwrite_option
=
"@resurrect-never-overwrite"
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