Skip to content

Instantly share code, notes, and snippets.

@blackfyre
Created September 17, 2025 09:06
Show Gist options
  • Save blackfyre/45dc6d785c0a3d2e0f8354413448f5ff to your computer and use it in GitHub Desktop.
Save blackfyre/45dc6d785c0a3d2e0f8354413448f5ff to your computer and use it in GitHub Desktop.
Setup Debian/Fedora envs
#!/usr/bin/env bash
set -euo pipefail
# --- Config ---
BIN_DIR="$HOME/bin"
BASHRC="$HOME/.bashrc"
# --- Ensure directories ---
mkdir -p "$BIN_DIR"
# --- Package install ---
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update -y
sudo apt-get install -y \
git curl wget unzip jq htop ncdu fzf tree \
nano screen podman mc \
lsd bat bash-completion
elif command -v dnf >/dev/null 2>&1; then
sudo dnf install -y \
git curl wget unzip jq htop ncdu fzf tree \
nano screen podman mc \
lsd bat bash-completion
fi
# --- Install Starship prompt ---
if ! command -v starship >/dev/null 2>&1; then
curl -sS https://starship.rs/install.sh | sh
mkdir -p ~/.config
starship preset no-nerd-font -o ~/.config/starship.toml
fi
# --- Install Superfile ---
if ! command -v spf >/dev/null 2>&1; then
bash -c "$(curl -sLo- https://superfile.netlify.app/install.sh)"
fi
# --- Helper function to add alias if missing ---
add_alias() {
local name="$1"
local cmd="$2"
if ! grep -qE "alias $name=" "$BASHRC"; then
echo "alias $name='$cmd'" >> "$BASHRC"
fi
}
# --- Update .bashrc safely ---
# Add PATH, bash-completion, Starship only once
if ! grep -q "## DevOps Bootstrap Start" "$BASHRC"; then
cat <<'EOF' >> "$BASHRC"
## DevOps Bootstrap Start
# Add ~/bin to PATH
export PATH="$HOME/bin:$PATH"
# Enable bash-completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Starship prompt init
eval "$(starship init bash)"
## DevOps Bootstrap End
EOF
fi
# --- Add aliases individually if they don’t exist ---
add_alias ll "lsd -alF"
add_alias la "lsd -A"
add_alias l "lsd -CF"
if command -v batcat >/dev/null 2>&1; then
add_alias bcat "batcat --style=plain --paging=never"
elif command -v bat >/dev/null 2>&1; then
add_alias bcat "bat --style=plain --paging=never"
fi
add_alias gs "git status"
add_alias ga "git add"
add_alias gc "git commit -m"
add_alias gp "git push"
add_alias rm "rm -i"
# --- Git defaults ---
git config --global core.editor nano
git config --global pull.rebase false
git config --global init.defaultBranch main
echo "✅ Bootstrap complete. Run 'source ~/.bashrc' to activate."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment