Resurrect file prefix and extension vars

This commit is contained in:
Bruno Sutic 2017-06-04 00:31:17 +02:00
parent 9d81e8d026
commit fe8390a578
No known key found for this signature in database
GPG Key ID: CAFA7B1B2914ED81
2 changed files with 4 additions and 2 deletions

View File

@ -2,6 +2,8 @@ default_resurrect_dir="$HOME/.tmux/resurrect"
resurrect_dir_option="@resurrect-dir" resurrect_dir_option="@resurrect-dir"
SUPPORTED_VERSION="1.9" SUPPORTED_VERSION="1.9"
RESURRECT_FILE_PREFIX="tmux_resurrect"
RESURRECT_FILE_EXTENSION="txt"
_RESURRECT_DIR="" _RESURRECT_DIR=""
_RESURRECT_FILE_PATH="" _RESURRECT_FILE_PATH=""
@ -111,7 +113,7 @@ _RESURRECT_DIR="$(resurrect_dir)"
resurrect_file_path() { resurrect_file_path() {
if [ -z "$_RESURRECT_FILE_PATH" ]; then if [ -z "$_RESURRECT_FILE_PATH" ]; then
local timestamp="$(date +"%Y-%m-%dT%H:%M:%S")" local timestamp="$(date +"%Y-%m-%dT%H:%M:%S")"
echo "$(resurrect_dir)/tmux_resurrect_${timestamp}.txt" echo "$(resurrect_dir)/${RESURRECT_FILE_PREFIX}_${timestamp}.${RESURRECT_FILE_EXTENSION}"
else else
echo "$_RESURRECT_FILE_PATH" echo "$_RESURRECT_FILE_PATH"
fi fi

View File

@ -281,7 +281,7 @@ dump_shell_history() {
remove_old_backups() { remove_old_backups() {
# remove backup files older than 30 days, but keep at least 5 copies of backup. # remove backup files older than 30 days, but keep at least 5 copies of backup.
local -a files local -a files
files=($(ls -t $(resurrect_dir)/*.txt | tail -n +6)) files=($(ls -t $(resurrect_dir)/${RESURRECT_FILE_PREFIX}_*.${RESURRECT_FILE_EXTENSION} | tail -n +6))
[[ ${#files[@]} -eq 0 ]] || find "${files[@]}" -type f -mtime +30 -delete [[ ${#files[@]} -eq 0 ]] || find "${files[@]}" -type f -mtime +30 -delete
} }