- Remove OpenClaw completion - Add hostname to prompt - Add Rust installation to setup.sh
77 lines
2.1 KiB
Bash
77 lines
2.1 KiB
Bash
set -euo pipefail
|
|
|
|
# CLI: parse flags
|
|
PROMPT_DELETE=1
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--no-prompt|-n)
|
|
PROMPT_DELETE=0
|
|
shift
|
|
;;
|
|
--prompt|-p)
|
|
PROMPT_DELETE=1
|
|
shift
|
|
;;
|
|
*) break
|
|
esac
|
|
done
|
|
|
|
echo ">>> Bootstrapping new Debian-like machine..."
|
|
|
|
# 1. Update package list and install essentials
|
|
echo ">>> Installing bash, kitty, and vim..."
|
|
sudo apt update
|
|
sudo apt install -y bash kitty vim-gtk3 git curl
|
|
|
|
# Install Rust
|
|
echo ">>> Installing Rust..."
|
|
if ! command -v rustc &> /dev/null; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
fi
|
|
|
|
# 2. Clone your dotfiles (bare repo style)
|
|
if [ ! -d "$HOME/.dotfiles" ]; then
|
|
echo ">>> Cloning dotfiles repo..."
|
|
git clone --bare https://gitea.sjhl.nz/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! Handling conflicting dotfiles..."
|
|
mkdir -p "$HOME/.dotfiles-backup"
|
|
|
|
conflicts=$(dotfiles checkout 2>&1 | grep -E "\s+\." | awk '{print $1}')
|
|
if [ -n "$conflicts" ]; then
|
|
if [ "$PROMPT_DELETE" = "0" ]; then
|
|
while IFS= read -r f; do
|
|
[ -z "$f" ] && continue
|
|
mv "$f" "$HOME/.dotfiles-backup/$f"
|
|
done <<< "$conflicts"
|
|
else
|
|
while IFS= read -r f; do
|
|
[ -z "$f" ] && continue
|
|
if [ -t 1 ]; then
|
|
read -r -p "Move '$f' to backup? (y/N): " resp
|
|
case "$resp" in
|
|
[Yy]* ) mv "$f" "$HOME/.dotfiles-backup/$f" ;;
|
|
* ) echo "Skipping '$f'." ;;
|
|
esac
|
|
else
|
|
echo "Non-interactive environment detected; skipping '$f'."
|
|
fi
|
|
done <<< "$conflicts"
|
|
fi
|
|
fi
|
|
dotfiles checkout
|
|
fi
|
|
|
|
dotfiles config --local status.showUntrackedFiles no
|
|
|
|
echo ">>> Done! Bash, kitty, vim, and dotfiles are ready."
|