Disable autosave when interval is set to 0

pull/7/head
Bruno Sutic 2015-02-12 15:42:18 +01:00
parent 2e57be38e4
commit aa01161701
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
2 changed files with 11 additions and 2 deletions

View File

@ -5,3 +5,4 @@
- run the save script in the background
- do not start saving right after tmux is started
- add a check for tmux version to the initializer script
- when interval is set to '0' autosave is disabled

View File

@ -6,9 +6,17 @@ source "$CURRENT_DIR/helpers.sh"
source "$CURRENT_DIR/variables.sh"
source "$CURRENT_DIR/shared.sh"
get_interval() {
get_tmux_option "$auto_save_interval_option" "$auto_save_interval_default"
}
auto_save_not_disabled() {
[ "$(get_interval)" -gt 0 ]
}
enough_time_since_last_run_passed() {
local last_saved_timestamp="$(get_tmux_option "$last_auto_save_option" "0")"
local interval_minutes="$(get_tmux_option "$auto_save_interval_option" "$auto_save_interval_default")"
local interval_minutes="$(get_interval)"
local interval_seconds="$((interval_minutes * 60))"
local next_run="$((last_saved_timestamp + $interval_seconds))"
[ "$(current_timestamp)" -ge "$next_run" ]
@ -23,7 +31,7 @@ fetch_and_run_tmux_resurrect_save_script() {
}
main() {
if supported_tmux_version_ok && enough_time_since_last_run_passed; then
if supported_tmux_version_ok && auto_save_not_disabled && enough_time_since_last_run_passed; then
fetch_and_run_tmux_resurrect_save_script
fi
}