From ed3854448fb2642e9a88e3f777b60c370f4cd994 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Fri, 13 Nov 2015 10:58:20 +0100 Subject: [PATCH] Adding function to delete old tarsnap archives. --- zsh_functions | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/zsh_functions b/zsh_functions index 5102e6d..5666fa1 100644 --- a/zsh_functions +++ b/zsh_functions @@ -83,3 +83,19 @@ pacman_disowned(){ virtual_env_prompt() { REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) } } + +delete-old-archives() { + archives=$(sudo tarsnap --list-archives | sort) + del_archives=$(echo $archives | head -n $(($(echo $archives | wc -l) - 3))) + del_archives=("${(@f)del_archives}") + for archive in $del_archives + do + read -q "reply?Do you want to delete '$archive' ? " + echo "" + if [[ $reply == "y" ]] + then + echo "Deleting '$archive' ..." + sudo tarsnap -d -f "$archive" + fi + done +}