From aa011617013dfb29436cc437f6e6edfa22f2b30c Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Thu, 12 Feb 2015 15:42:18 +0100 Subject: [PATCH] Disable autosave when interval is set to 0 --- CHANGELOG.md | 1 + scripts/resurrect_auto_save.sh | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1196859..ce51816 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/scripts/resurrect_auto_save.sh b/scripts/resurrect_auto_save.sh index 608d882..d8255b3 100755 --- a/scripts/resurrect_auto_save.sh +++ b/scripts/resurrect_auto_save.sh @@ -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 }