mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-11-10 14:01:26 +00:00
auto remove old backup files
remove backup files older than 30 days, but keep at least 5 copies of backup. Fixes #102.
This commit is contained in:
parent
7e0bfcb7e9
commit
9d81e8d026
@ -278,6 +278,13 @@ dump_shell_history() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_old_backups() {
|
||||||
|
# remove backup files older than 30 days, but keep at least 5 copies of backup.
|
||||||
|
local -a files
|
||||||
|
files=($(ls -t $(resurrect_dir)/*.txt | tail -n +6))
|
||||||
|
[[ ${#files[@]} -eq 0 ]] || find "${files[@]}" -type f -mtime +30 -delete
|
||||||
|
}
|
||||||
|
|
||||||
save_all() {
|
save_all() {
|
||||||
local resurrect_file_path="$(resurrect_file_path)"
|
local resurrect_file_path="$(resurrect_file_path)"
|
||||||
local last_resurrect_file="$(last_resurrect_file)"
|
local last_resurrect_file="$(last_resurrect_file)"
|
||||||
@ -300,6 +307,7 @@ save_all() {
|
|||||||
if save_shell_history_option_on; then
|
if save_shell_history_option_on; then
|
||||||
dump_shell_history
|
dump_shell_history
|
||||||
fi
|
fi
|
||||||
|
remove_old_backups
|
||||||
}
|
}
|
||||||
|
|
||||||
show_output() {
|
show_output() {
|
||||||
|
Loading…
Reference in New Issue
Block a user