#!/bin/bash set -euo pipefail TAG=.bak-$(date +%Y%m%d) SRC_DIRS=( "$HOME/.local/share/nvim" "$HOME/.local/state/nvim" "$HOME/.cache/nvim" ) # Show plan and confirm printf "This will back up and clean your Neovim directories.\n" printf "Backup suffix to be appended: %s\n\n" "$TAG" printf "Plan:\n" for SRC in "${SRC_DIRS[@]}"; do if [ -e "$SRC" ]; then DEST="${SRC}${TAG}" printf " %s -> %s\n" "$SRC" "$DEST" fi done printf "\n" read -r -p "Are you sure you want to proceed? [y/N]: " CONFIRM case ${CONFIRM:-} in [yY]|[yY][eE][sS]) ;; *) printf "Aborted!\n"; exit 0;; esac # Perform moves, skipping missing sources for SRC in "${SRC_DIRS[@]}"; do if [ -e "$SRC" ]; then DEST="${SRC}${TAG}" printf "Moving %s -> %s\n" "$SRC" "$DEST" mv "$SRC" "$DEST" fi done printf "Done!"