mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-12-25 00:28:49 +00:00
Make backup retention period configurable
For instance `tmux set-option -g @resurrect-delete-backup-after 1` to only keep 1 day of backups. Closes 252.
This commit is contained in:
parent
5f5f9d8fd5
commit
e815c50f13
@ -30,6 +30,8 @@
|
||||
e.g. `vim -S Session1.vim`.
|
||||
- Enable restoring command arguments for inline strategies with `*` character.
|
||||
- Kill session "0" if it wasn't restored.
|
||||
- Add `@resurrect-delete-backup-after` option to specify how many days of
|
||||
backups to keep - default is 30.
|
||||
|
||||
### v2.4.0, 2015-02-23
|
||||
- add "tmux-test"
|
||||
|
@ -269,11 +269,12 @@ dump_shell_history() {
|
||||
}
|
||||
|
||||
remove_old_backups() {
|
||||
# remove resurrect files older than 30 days, but keep at least 5 copies of backup.
|
||||
# remove resurrect files older than 30 days (default), but keep at least 5 copies of backup.
|
||||
local delete_after="$(get_tmux_option "$delete_backup_after_option" "$default_delete_backup_after")"
|
||||
local -a files
|
||||
files=($(ls -t $(resurrect_dir)/${RESURRECT_FILE_PREFIX}_*.${RESURRECT_FILE_EXTENSION} | tail -n +6))
|
||||
[[ ${#files[@]} -eq 0 ]] ||
|
||||
find "${files[@]}" -type f -mtime +30 -exec rm -v "{}" \;
|
||||
find "${files[@]}" -type f -mtime "+${delete_after}" -exec rm -v "{}" \;
|
||||
}
|
||||
|
||||
save_all() {
|
||||
|
@ -46,3 +46,6 @@ overwrite_option="@resurrect-never-overwrite"
|
||||
|
||||
# Hooks are set via ${hook_prefix}${name}, i.e. "@resurrect-hook-post-save-all"
|
||||
hook_prefix="@resurrect-hook-"
|
||||
|
||||
delete_backup_after_option="@resurrect-delete-backup-after"
|
||||
default_delete_backup_after="30" # days
|
||||
|
Loading…
Reference in New Issue
Block a user