46 lines
1.2 KiB
Bash
46 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
echo ">>> Bootstrapping new Debian-like machine..."
|
|
|
|
# 1. Update package list and install essentials
|
|
echo ">>> Installing bash, tmux, and vim..."
|
|
sudo apt update
|
|
sudo apt install -y bash tmux vim git curl
|
|
|
|
# 2. Clone your dotfiles (bare repo style)
|
|
if [ ! -d "$HOME/.dotfiles" ]; then
|
|
echo ">>> Cloning dotfiles repo..."
|
|
git clone --bare https://gitea.james-server.duckdns.org/james/dotfiles $HOME/.dotfiles
|
|
else
|
|
echo ">>> Dotfiles repo already exists."
|
|
fi
|
|
|
|
|
|
# 3. Checkout dotfiles
|
|
dotfiles() {
|
|
/usr/bin/git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME" "$@"
|
|
}
|
|
echo ">>> Checking out dotfiles..."
|
|
if ! dotfiles checkout; then
|
|
echo ">>> Conflicts detected! Backing up existing dotfiles..."
|
|
mkdir -p $HOME/.dotfiles-backup
|
|
dotfiles checkout 2>&1 | grep -E "\s+\." | awk '{print $1}' | \
|
|
xargs -I{} mv {} $HOME/.dotfiles-backup/{}
|
|
dotfiles checkout
|
|
fi
|
|
|
|
dotfiles config --local status.showUntrackedFiles no
|
|
|
|
# 4. setup tmux
|
|
mkdir -p ~/.tmux/plugins
|
|
if [ ! -d ~/.tmux/plugins/tpm ]; then
|
|
echo ">>> Installing Tmux Plugin Manager..."
|
|
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
|
fi
|
|
|
|
|
|
|
|
echo ">>> Done! Bash, tmux, vim, and dotfiles are ready."
|
|
|