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
0133c7a9
Commit
0133c7a9
authored
Jan 19, 2018
by
Sergey Vlasov
Committed by
Ash Berlin-Taylor
Aug 17, 2018
Browse files
Save and restore hooks
parent
42f77b30
Changes
6
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
0133c7a9
...
...
@@ -90,6 +90,7 @@ You should now be able to use the plugin.
**Configuration**
-
[
Changing the default key bindings
](
docs/custom_key_bindings.md
)
.
-
[
Setting up hooks on save & restore
](
docs/hooks.md
)
.
-
Only a conservative list of programs is restored by default:
<br/>
`vi vim nvim emacs man less more tail top htop irssi weechat mutt`
.
<br/>
[
Restoring programs doc
](
docs/restoring_programs.md
)
explains how to restore
...
...
docs/hooks.md
0 → 100644
View file @
0133c7a9
# Save & Restore Hooks
Hooks allow to set custom commands that will be executed during session save and restore.
Currently the following hooks are supported:
-
`@resurrect-save-hook`
- executed after session save
-
`@resurrect-restore-hook`
- executed before session restore
Here is an example how to save and restore window geometry for most terminals in X11.
Add this to
`.tmux.conf`
:
set -g @resurrect-save-hook 'eval $(xdotool getwindowgeometry --shell $WINDOWID); echo 0,$X,$Y,$WIDTH,$HEIGHT > $HOME/.tmux/resurrect/geometry'
set -g @resurrect-restore-hook 'wmctrl -i -r $WINDOWID -e $(cat $HOME/.tmux/resurrect/geometry)'
scripts/helpers.sh
View file @
0133c7a9
...
...
@@ -148,3 +148,14 @@ resurrect_history_file() {
local
shell_name
=
"
$2
"
echo
"
$(
resurrect_dir
)
/
${
shell_name
}
_history-
${
pane_id
}
"
}
# hook helpers
save_hook
()
{
get_tmux_option
"
$save_hook_option
"
"
$save_hook_default
"
}
restore_hook
()
{
get_tmux_option
"
$restore_hook_option
"
"
$restore_hook_default
"
}
scripts/restore.sh
View file @
0133c7a9
...
...
@@ -344,6 +344,9 @@ restore_active_and_alternate_sessions() {
main
()
{
if
supported_tmux_version_ok
&&
check_saved_session_exists
;
then
start_spinner
"Restoring..."
"Tmux restore complete!"
if
[
-n
"
$(
restore_hook
)
"
]
;
then
eval
"
$(
restore_hook
)
"
fi
restore_all_panes
restore_pane_layout_for_each_window
>
/dev/null 2>&1
if
save_shell_history_option_on
;
then
...
...
scripts/save.sh
View file @
0133c7a9
...
...
@@ -314,6 +314,9 @@ main() {
stop_spinner
display_message
"Tmux environment saved!"
fi
if
[
-n
"
$(
save_hook
)
"
]
;
then
eval
"
$(
save_hook
)
"
fi
fi
}
main
scripts/variables.sh
View file @
0133c7a9
...
...
@@ -42,3 +42,9 @@ shell_history_option="@resurrect-save-shell-history"
# set to 'on' to ensure panes are never ever overwritten
overwrite_option
=
"@resurrect-never-overwrite"
# Hooks
restore_hook_default
=
""
restore_hook_option
=
"@resurrect-restore-hook"
save_hook_default
=
""
save_hook_option
=
"@resurrect-save-hook"
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