Last active
March 2, 2025 12:04
-
-
Save dpi0/c45bf3ed0d4c6067cc9961c0643ce573 to your computer and use it in GitHub Desktop.
vim installation and set up on any debian/arch/fedora machine
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 | |
PKG="vim" | |
CONFIG_FILE="$HOME/.vimrc" | |
MY_REPO="https://github.com/dpi0/sh" | |
CONFIG_URL="${MY_REPO}/raw/main/.vimrc" | |
# Backup existing config | |
timestamped_backup() { | |
local target_file="$1" | |
if [ -f "$target_file" ]; then | |
local timestamp=$(date +%Y%m%d%H%M%S) | |
mv "$target_file" "${target_file}.$timestamp" | |
echo "Existing config backed up!" | |
fi | |
} | |
# Download new config | |
download_config() { | |
curl -fsSL "$CONFIG_URL" -o "$CONFIG_FILE" | |
} | |
# Install package based on system type | |
install_pkg() { | |
if command -v apt &> /dev/null; then sudo apt install -y $PKG | |
elif command -v pacman &> /dev/null; then sudo pacman -Syu --noconfirm $PKG | |
elif command -v dnf &> /dev/null; then sudo dnf install -y $PKG | |
else echo "Unsupported system. Install manually..." | |
fi | |
} | |
# Ensure required dependencies are installed | |
curl -fsSL bin.dpi0.cloud/git | sh | |
if ! command -v $PKG &> /dev/null; then | |
echo "$PKG not found. Installing..." | |
install_pkg | |
else | |
echo "$PKG is already installed." | |
fi | |
# Execute functions | |
timestamped_backup "$CONFIG_FILE" | |
download_config | |
echo "$PKG installation and config setup complete. 🎉" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment