Installer and update script enhancements.
This commit is contained in:
@@ -3,9 +3,47 @@
|
||||
# Update Dotfiles Script
|
||||
# ============================================================================
|
||||
# Updates dotfiles from the git repository and relinks files
|
||||
#
|
||||
# Usage:
|
||||
# update-dotfiles.sh # Pull and re-run install
|
||||
# update-dotfiles.sh --skip-deps # Pull and re-run install without deps
|
||||
# update-dotfiles.sh --pull-only # Only git pull, don't re-run install
|
||||
# ============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# ============================================================================
|
||||
# Options
|
||||
# ============================================================================
|
||||
|
||||
SKIP_DEPS=true # Default to skipping deps on updates
|
||||
PULL_ONLY=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--skip-deps)
|
||||
SKIP_DEPS=true
|
||||
;;
|
||||
--with-deps)
|
||||
SKIP_DEPS=false
|
||||
;;
|
||||
--pull-only)
|
||||
PULL_ONLY=true
|
||||
;;
|
||||
--help|-h)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " --skip-deps Skip dependency check (default for updates)"
|
||||
echo " --with-deps Run full dependency check"
|
||||
echo " --pull-only Only git pull, don't re-run install script"
|
||||
echo " --help Show this help message"
|
||||
echo
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# ============================================================================
|
||||
# Load Configuration
|
||||
# ============================================================================
|
||||
@@ -32,6 +70,7 @@ fi
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
print_success() {
|
||||
@@ -46,6 +85,10 @@ print_error() {
|
||||
echo -e "${RED}✗${NC} $1"
|
||||
}
|
||||
|
||||
print_step() {
|
||||
echo -e "${GREEN}==>${NC} $1"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Main
|
||||
# ============================================================================
|
||||
@@ -59,21 +102,32 @@ fi
|
||||
|
||||
cd "$DOTFILES_DIR"
|
||||
|
||||
echo "Updating dotfiles from repository..."
|
||||
print_step "Updating dotfiles from repository..."
|
||||
git pull origin "$DOTFILES_BRANCH"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_success "Dotfiles updated successfully"
|
||||
|
||||
if [[ "$PULL_ONLY" == true ]]; then
|
||||
echo
|
||||
print_success "Pull complete (--pull-only mode)"
|
||||
echo "Run ./install.sh manually to re-link files"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f "$DOTFILES_DIR/install.sh" ]; then
|
||||
echo
|
||||
read -p "Run install script to update links? [Y/n]: " response
|
||||
response=${response:-y}
|
||||
|
||||
if [[ "$response" =~ ^[Yy]$ ]]; then
|
||||
if [[ "$SKIP_DEPS" == true ]]; then
|
||||
"$DOTFILES_DIR/install.sh" --skip-deps
|
||||
else
|
||||
"$DOTFILES_DIR/install.sh"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
print_success "Update complete!"
|
||||
|
||||
@@ -23,7 +23,9 @@ USER_WEBSITE=""
|
||||
USER_GITHUB=""
|
||||
|
||||
# --- Feature Toggles ---
|
||||
# Set to "true" or "false" to control what gets installed
|
||||
# Set to "true", "false", or "ask" to control what gets installed
|
||||
# Use "auto" to skip if already installed (default for deps)
|
||||
INSTALL_DEPS="auto" # "auto" (skip if installed), "true", "false", or "ask"
|
||||
INSTALL_ESPANSO="ask" # "true", "false", or "ask"
|
||||
INSTALL_FZF="ask"
|
||||
INSTALL_BAT="ask"
|
||||
@@ -36,7 +38,7 @@ THEME_TIMER_THRESHOLD=10 # Show elapsed time for commands longer than
|
||||
THEME_PATH_TRUNCATE_LENGTH=32 # Truncate path display after N characters
|
||||
|
||||
# --- Espanso Settings ---
|
||||
ESPANSO_TRIGGER_PREFIX=".." # Prefix for all triggers (e.g., "..date")
|
||||
ESPANSO_TRIGGER_PREFIX=".." # Prefix for all Aaron D. Lee's normal triggers (e.g., "..date")
|
||||
|
||||
# --- Snapper Settings (CachyOS/Arch with btrfs) ---
|
||||
SNAPPER_CONFIG="root"
|
||||
|
||||
92
install.sh
92
install.sh
@@ -7,11 +7,48 @@
|
||||
# Or:
|
||||
# git clone https://github.com/adlee-was-taken/dotfiles.git && cd dotfiles && ./install.sh
|
||||
#
|
||||
# Options:
|
||||
# --skip-deps Skip dependency installation (for re-runs)
|
||||
# --deps-only Only install dependencies, then exit
|
||||
# --help Show help
|
||||
#
|
||||
# Fork this repo? Edit dotfiles.conf with your settings.
|
||||
# ============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# ============================================================================
|
||||
# Command Line Options
|
||||
# ============================================================================
|
||||
|
||||
SKIP_DEPS=false
|
||||
DEPS_ONLY=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--skip-deps)
|
||||
SKIP_DEPS=true
|
||||
;;
|
||||
--deps-only)
|
||||
DEPS_ONLY=true
|
||||
;;
|
||||
--help|-h)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " --skip-deps Skip dependency installation (useful for re-runs)"
|
||||
echo " --deps-only Only install dependencies, then exit"
|
||||
echo " --help Show this help message"
|
||||
echo
|
||||
echo "Configuration:"
|
||||
echo " Edit dotfiles.conf to customize installation behavior"
|
||||
echo " Set INSTALL_DEPS=\"false\" to always skip dependencies"
|
||||
echo
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# ============================================================================
|
||||
# Load Configuration
|
||||
# ============================================================================
|
||||
@@ -32,6 +69,7 @@ load_config() {
|
||||
DOTFILES_REPO_URL="https://github.com/${DOTFILES_GITHUB_USER}/${DOTFILES_REPO_NAME}.git"
|
||||
|
||||
# Feature toggles
|
||||
INSTALL_DEPS="${INSTALL_DEPS:-auto}"
|
||||
INSTALL_ESPANSO="${INSTALL_ESPANSO:-ask}"
|
||||
INSTALL_FZF="${INSTALL_FZF:-ask}"
|
||||
INSTALL_BAT="${INSTALL_BAT:-ask}"
|
||||
@@ -141,7 +179,31 @@ detect_os() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if core dependencies are already installed
|
||||
check_core_deps() {
|
||||
command -v git &>/dev/null && command -v curl &>/dev/null && command -v zsh &>/dev/null
|
||||
}
|
||||
|
||||
install_dependencies() {
|
||||
# Skip if --skip-deps flag
|
||||
if [[ "$SKIP_DEPS" == true ]]; then
|
||||
print_step "Skipping dependencies (--skip-deps)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Skip if INSTALL_DEPS=false in config
|
||||
if [[ "${INSTALL_DEPS}" == "false" || "${INSTALL_DEPS}" == "no" || "${INSTALL_DEPS}" == "0" ]]; then
|
||||
print_step "Skipping dependencies (INSTALL_DEPS=false in config)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Auto-detect: skip if deps already installed (default behavior)
|
||||
if [[ "${INSTALL_DEPS}" == "auto" ]] && check_core_deps; then
|
||||
print_step "Dependencies check"
|
||||
print_success "Core dependencies already installed (git, curl, zsh)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
print_step "Installing dependencies"
|
||||
|
||||
case "$OS" in
|
||||
@@ -216,15 +278,15 @@ backup_existing_configs() {
|
||||
if [ "$backup_needed" = true ]; then
|
||||
print_success "Backups saved to: $BACKUP_DIR"
|
||||
else
|
||||
print_success "No backups needed"
|
||||
print_success "No backups needed (files already symlinked or don't exist)"
|
||||
fi
|
||||
}
|
||||
|
||||
install_oh_my_zsh() {
|
||||
print_step "Installing oh-my-zsh"
|
||||
print_step "Checking oh-my-zsh"
|
||||
|
||||
if [ -d "$HOME/.oh-my-zsh" ]; then
|
||||
print_warning "oh-my-zsh already installed"
|
||||
print_success "oh-my-zsh already installed"
|
||||
else
|
||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
||||
print_success "oh-my-zsh installed"
|
||||
@@ -278,7 +340,7 @@ link_dotfiles() {
|
||||
}
|
||||
|
||||
set_zsh_default() {
|
||||
print_step "Setting zsh as default shell"
|
||||
print_step "Checking default shell"
|
||||
|
||||
if [ "$SHELL" != "$(which zsh)" ]; then
|
||||
case "$SET_ZSH_DEFAULT" in
|
||||
@@ -302,13 +364,13 @@ set_zsh_default() {
|
||||
}
|
||||
|
||||
install_espanso() {
|
||||
print_step "Installing espanso (text expander)"
|
||||
|
||||
if command -v espanso &> /dev/null; then
|
||||
print_warning "espanso already installed"
|
||||
print_success "espanso already installed"
|
||||
return 0
|
||||
fi
|
||||
|
||||
print_step "Installing espanso (text expander)"
|
||||
|
||||
case "$OS" in
|
||||
ubuntu|debian)
|
||||
sudo apt-get install -y wget
|
||||
@@ -389,6 +451,8 @@ install_optional_tools() {
|
||||
if should_install "$INSTALL_ESPANSO" "espanso (text expander)"; then
|
||||
install_espanso
|
||||
fi
|
||||
else
|
||||
print_success "espanso already installed"
|
||||
fi
|
||||
|
||||
# fzf
|
||||
@@ -398,6 +462,8 @@ install_optional_tools() {
|
||||
~/.fzf/install --all
|
||||
print_success "fzf installed"
|
||||
fi
|
||||
else
|
||||
print_success "fzf already installed"
|
||||
fi
|
||||
|
||||
# bat
|
||||
@@ -411,6 +477,8 @@ install_optional_tools() {
|
||||
esac
|
||||
print_success "bat installed"
|
||||
fi
|
||||
else
|
||||
print_success "bat already installed"
|
||||
fi
|
||||
|
||||
# eza
|
||||
@@ -424,6 +492,8 @@ install_optional_tools() {
|
||||
esac
|
||||
print_success "eza installed"
|
||||
fi
|
||||
else
|
||||
print_success "eza already installed"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -436,6 +506,14 @@ main() {
|
||||
|
||||
detect_os
|
||||
|
||||
# Handle --deps-only
|
||||
if [[ "$DEPS_ONLY" == true ]]; then
|
||||
install_dependencies
|
||||
echo
|
||||
print_success "Dependencies installed. Run without --deps-only to continue."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ask_yes_no "Install/update dotfiles?"; then
|
||||
install_dependencies
|
||||
clone_or_update_dotfiles
|
||||
|
||||
Reference in New Issue
Block a user