From eef844c74747226ac327783300c3822233e595e7 Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Thu, 1 Jun 2017 17:03:39 +0200 Subject: [PATCH] Memoize return of resurrect path functions --- scripts/helpers.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/helpers.sh b/scripts/helpers.sh index 0d40b6d..a4caafc 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -2,6 +2,8 @@ default_resurrect_dir="$HOME/.tmux/resurrect" resurrect_dir_option="@resurrect-dir" SUPPORTED_VERSION="1.9" +_RESURRECT_DIR="" +_RESURRECT_FILE_PATH="" d=$'\t' @@ -94,13 +96,21 @@ pane_content_files_restore_from_archive() { # path helpers resurrect_dir() { - local path="$(get_tmux_option "$resurrect_dir_option" "$default_resurrect_dir")" - echo "${path/#\~/$HOME}" # expands tilde if used with @resurrect-dir + if [ -z "$_RESURRECT_DIR" ]; then + local path="$(get_tmux_option "$resurrect_dir_option" "$default_resurrect_dir")" + echo "${path/#\~/$HOME}" # expands tilde if used with @resurrect-dir + else + echo "$_RESURRECT_DIR" + fi } resurrect_file_path() { - local timestamp="$(date +"%Y-%m-%dT%H:%M:%S")" - echo "$(resurrect_dir)/tmux_resurrect_${timestamp}.txt" + if [ -z "$_RESURRECT_FILE_PATH" ]; then + local timestamp="$(date +"%Y-%m-%dT%H:%M:%S")" + echo "$(resurrect_dir)/tmux_resurrect_${timestamp}.txt" + else + echo "$_RESURRECT_FILE_PATH" + fi } last_resurrect_file() {