mirror of
https://github.com/tmux-plugins/tmux-continuum.git
synced 2024-11-25 05:38:47 +00:00
Enable auto load
This commit is contained in:
parent
da2cc780d5
commit
99658eda98
@ -1,6 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
### master
|
### master
|
||||||
|
- enable automatic environment restore when tmux is started
|
||||||
|
|
||||||
### v1.0.0, 2015-02-12
|
### v1.0.0, 2015-02-12
|
||||||
- first working version
|
- first working version
|
||||||
|
@ -18,12 +18,27 @@ add_resurrect_save_interpolation() {
|
|||||||
set_tmux_option "status-right" "$new_value"
|
set_tmux_option "status-right" "$new_value"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# on tmux server start, when tmux.conf is sourced there are no sessions and
|
||||||
|
# `tmux has` reports 1
|
||||||
|
just_started_tmux_server() {
|
||||||
|
tmux has
|
||||||
|
[ $? -eq 1 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
start_auto_restore_in_background() {
|
||||||
|
$CURRENT_DIR/scripts/resurrect_auto_restore.sh &
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
if supported_tmux_version_ok; then
|
if supported_tmux_version_ok; then
|
||||||
# Don't start saving right after tmux is started.
|
# Don't start saving right after tmux is started.
|
||||||
# We wanna give user a chance to restore previous session.
|
# We wanna give user a chance to restore previous session.
|
||||||
set_last_save_timestamp
|
set_last_save_timestamp
|
||||||
add_resurrect_save_interpolation
|
add_resurrect_save_interpolation
|
||||||
|
|
||||||
|
if just_started_tmux_server; then
|
||||||
|
start_auto_restore_in_background
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
main
|
main
|
||||||
|
27
scripts/resurrect_auto_restore.sh
Executable file
27
scripts/resurrect_auto_restore.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
source "$CURRENT_DIR/variables.sh"
|
||||||
|
|
||||||
|
auto_restore_not_disabled() {
|
||||||
|
local auto_restore_value="$(get_tmux_option "$auto_restore_option" "$auto_restore_default")"
|
||||||
|
[ "$auto_restore_value" == "on" ] && [ ! -f "$auto_restore_halt_file" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch_and_run_tmux_resurrect_restore_script() {
|
||||||
|
# give tmux some time to start and source all the plugins
|
||||||
|
sleep 1
|
||||||
|
local resurrect_restore_script_path="$(get_tmux_option "$resurrect_restore_path_option" "")"
|
||||||
|
if [ -n "$resurrect_restore_script_path" ]; then
|
||||||
|
"$resurrect_restore_script_path"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
if auto_restore_not_disabled; then
|
||||||
|
fetch_and_run_tmux_resurrect_restore_script
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
main
|
@ -9,3 +9,8 @@ auto_save_interval_option="@resurrect-auto-save-interval"
|
|||||||
|
|
||||||
# time when the tmux environment was last saved (unix timestamp)
|
# time when the tmux environment was last saved (unix timestamp)
|
||||||
last_auto_save_option="@resurrect-auto-save-last-timestamp"
|
last_auto_save_option="@resurrect-auto-save-last-timestamp"
|
||||||
|
|
||||||
|
auto_restore_option="@resurrect-auto-restore"
|
||||||
|
auto_restore_default="off"
|
||||||
|
|
||||||
|
auto_restore_halt_file="${HOME}/tmux_no_auto_restore"
|
||||||
|
Loading…
Reference in New Issue
Block a user