Created
November 28, 2025 18:16
-
-
Save AxDSan/611c8c322dc38cb61fad5e2ebb5201c3 to your computer and use it in GitHub Desktop.
Make Fastfetch Nicer!
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # ============================================================================= | |
| # Robust fastfetch config installer with backups and safety checks | |
| # Author: You (or me π) | |
| # Config source: https://github.com/harilvfs/fastfetch (old-days branch) | |
| # ============================================================================= | |
| set -euo pipefail # Strict mode: exit on error, undefined var, or pipe failure | |
| CONFIG_URL="https://raw.githubusercontent.com/harilvfs/fastfetch/refs/heads/old-days/fastfetch/config.jsonc" | |
| TARGET_DIR="$HOME/.config/fastfetch" | |
| TARGET_FILE="$TARGET_DIR/config.jsonc" | |
| BACKUP_DIR="$TARGET_DIR/backups" | |
| TIMESTAMP=$(date +"%Y%m%d_%H%M%S") | |
| BACKUP_FILE="$BACKUP_DIR/config.jsonc.backup.$TIMESTAMP" | |
| echo "π Installing custom fastfetch config (old-days theme)" | |
| # 1. Check if fastfetch is even installed | |
| if ! command -v fastfetch >/dev/null 2>&1; then | |
| echo "β οΈ fastfetch is not installed. Installing it first is recommended." | |
| echo " On Debian/Ubuntu: sudo apt install fastfetch" | |
| echo " On Arch: sudo pacman -S fastfetch" | |
| echo " On Fedora: sudo dnf install fastfetch" | |
| read -p "Continue anyway? (y/N): " -n 1 -r | |
| echo | |
| if [[ ! $REPLY =~ ^[Yy]$ ]]; then | |
| echo "Aborted." | |
| exit 1 | |
| fi | |
| fi | |
| # 2. Create directories | |
| mkdir -p "$TARGET_DIR" | |
| mkdir -p "$BACKUP_DIR" | |
| # 3. Backup existing config if it exists and is not a symlink | |
| if [[ -f "$TARGET_FILE" && ! -L "$TARGET_FILE" ]]; then | |
| echo "πΎ Backing up existing config β $BACKUP_FILE" | |
| cp "$TARGET_FILE" "$BACKUP_FILE" | |
| echo " (Old configs are kept forever in $BACKUP_DIR)" | |
| fi | |
| # 4. Download the new config with retry logic | |
| echo "β¬οΈ Downloading custom config..." | |
| for i in {1..5}; do | |
| if wget --quiet --timeout=10 --tries=1 -O "$TARGET_FILE.tmp" "$CONFIG_URL"; then | |
| mv "$TARGET_FILE.tmp" "$TARGET_FILE" | |
| echo "β Config downloaded and installed successfully!" | |
| break | |
| else | |
| echo "β οΈ Download attempt $i failed, retrying in 3 seconds..." | |
| sleep 3 | |
| fi | |
| done | |
| # Final check | |
| if [[ ! -f "$TARGET_FILE" ]]; then | |
| echo "β Failed to download the config after 5 attempts." | |
| echo " Check your internet or try again later." | |
| exit 1 | |
| fi | |
| # 5. Optional: show a preview (if fastfetch works) | |
| if command -v fastfetch >/dev/null 2>&1; then | |
| echo "πΌοΈ Preview (close with Ctrl+C if it hangs):" | |
| echo "ββββββββββββββββββββββββββββββββββββββββββββ" | |
| timeout 8 fastfetch || true | |
| echo "ββββββββββββββββββββββββββββββββββββββββββββ" | |
| fi | |
| echo | |
| echo "β All done!" | |
| echo " β’ Your old config(s) are safely backed up in:" | |
| echo " $BACKUP_DIR" | |
| echo " β’ Just close & reopen your terminal (or run 'exec \$SHELL')" | |
| echo " β’ Then type: fastfetch" | |
| echo | |
| echo "Enjoy the nostalgia! πΉοΈ" | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment