mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-11-22 04:18:48 +00:00
Memoize return of resurrect path functions
This commit is contained in:
parent
b7a4ee2a40
commit
eef844c747
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user