Created
January 5, 2024 20:34
-
-
Save kashifulhaque/f9e19d82b7790f63a1f9988871462c1c to your computer and use it in GitHub Desktop.
Compress the config files (Arch + KDE setup)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "A simple script compress my dotfiles" | |
echo "------------------------------------" | |
# Check if 'pigz' is installed or not | |
command_exists() { | |
command -v "$1" >/dev/null 2>&1 | |
} | |
# Check if pigz is installed, and install it if not | |
if ! command_exists pigz; then | |
echo "pigz is not installed. Installing using yay ..." | |
yay --noconfirm -S pigz | |
fi | |
# Files and folders to compress | |
BASHRC=~/.bashrc | |
CONDARC=~/.condarc | |
CONFIG=~/.config/ | |
GIT_CONFIG=~/.gitconfig | |
GTKRC=~/.gtkrc-2.0 | |
LOCAL=~/.local/ | |
ICONS=~/.icons/ | |
POSH_THEMES=~/.posh-themes/ | |
SSH=~/.ssh/ | |
# Generate a timestamp in the format YYYYMMDD_HHMMSS | |
TIMESTAMP=$(date +"%Y%m%d_%H%M%S") | |
echo "Current timestamp: $TIMESTAMP" | |
# Archive file name with the specified format and exclude list | |
ARCHIVE_FILE="archlinux_kde_${TIMESTAMP}.tar.gz" | |
EXCLUDE_LIST=$(find "$CONFIG_FOLDER" -maxdepth 1 -type d -exec du -sm {} + | awk '$1 > 2 {print "--exclude=" $2}' | tr '\n' ' ') | |
# Compression command | |
COMPRESS_CMD="tar --use-compress-program=pigz -cvf $ARCHIVE_FILE $EXCLUDE_LIST" | |
# Compression | |
echo "Compressing ..." | |
echo "---------------" | |
echo "$COMPRESS_CMD $BASHRC $CONDARC $CONFIG $GIT_CONFIG $GTKRC $LOCAL $ICONS $POSH_THEMES $SSH" | |
$COMPRESS_CMD $BASHRC $CONDARC $CONFIG $GIT_CONFIG $GTKRC $LOCAL $ICONS $POSH_THEMES $SSH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment