Memoize return of resurrect path functions

pull/133/merge
Bruno Sutic 2017-06-01 17:03:39 +02:00
parent b7a4ee2a40
commit eef844c747
No known key found for this signature in database
GPG Key ID: CAFA7B1B2914ED81
1 changed files with 14 additions and 4 deletions

View File

@ -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() {