Dotfiles update 2025-12-25 12:04
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
|
||||
set -e
|
||||
|
||||
# ============================================================================
|
||||
# Parse Arguments First (before sourcing, in case we need --help)
|
||||
# ============================================================================
|
||||
|
||||
SKIP_DEPS=true
|
||||
PULL_ONLY=false
|
||||
|
||||
@@ -26,86 +30,50 @@ for arg in "$@"; do
|
||||
esac
|
||||
done
|
||||
|
||||
# Load Configuration
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DOTFILES_CONF="${SCRIPT_DIR}/../dotfiles.conf"
|
||||
[[ -f "$DOTFILES_CONF" ]] || DOTFILES_CONF="$HOME/.dotfiles/dotfiles.conf"
|
||||
# ============================================================================
|
||||
# Source Bootstrap
|
||||
# ============================================================================
|
||||
|
||||
if [[ -f "$DOTFILES_CONF" ]]; then
|
||||
source "$DOTFILES_CONF"
|
||||
else
|
||||
DOTFILES_DIR="$HOME/.dotfiles"
|
||||
DOTFILES_BRANCH="main"
|
||||
DOTFILES_RAW_URL="https://raw.githubusercontent.com/adlee-was-taken/dotfiles/main"
|
||||
fi
|
||||
|
||||
# Source shared colors and utils (provides DF_WIDTH)
|
||||
source "$DOTFILES_DIR/zsh/lib/utils.zsh" 2>/dev/null || \
|
||||
source "$DOTFILES_DIR/zsh/lib/colors.zsh" 2>/dev/null || {
|
||||
source "${DOTFILES_HOME:-$HOME/.dotfiles}/zsh/lib/bootstrap.zsh" 2>/dev/null || {
|
||||
DF_GREEN=$'\033[0;32m' DF_YELLOW=$'\033[1;33m' DF_RED=$'\033[0;31m'
|
||||
DF_BLUE=$'\033[0;34m' DF_CYAN=$'\033[0;36m' DF_NC=$'\033[0m'
|
||||
DF_GREY=$'\033[38;5;242m' DF_LIGHT_BLUE=$'\033[38;5;39m'
|
||||
DF_BOLD=$'\033[1m' DF_DIM=$'\033[2m' DF_LIGHT_GREEN=$'\033[38;5;82m'
|
||||
DF_CYAN=$'\033[0;36m' DF_NC=$'\033[0m'
|
||||
DOTFILES_HOME="${DOTFILES_HOME:-$HOME/.dotfiles}"
|
||||
DOTFILES_BRANCH="${DOTFILES_BRANCH:-main}"
|
||||
df_print_header() { echo "=== $1 ==="; }
|
||||
df_print_success() { echo -e "${DF_GREEN}✓${DF_NC} $1"; }
|
||||
df_print_error() { echo -e "${DF_RED}✗${DF_NC} $1" >&2; }
|
||||
df_print_warning() { echo -e "${DF_YELLOW}⚠${DF_NC} $1"; }
|
||||
df_print_step() { echo -e "${DF_GREEN}==>${DF_NC} $1"; }
|
||||
}
|
||||
|
||||
# Use DF_WIDTH from utils.zsh or default to 66
|
||||
readonly WIDTH="${DF_WIDTH:-66}"
|
||||
|
||||
# ============================================================================
|
||||
# MOTD-style header
|
||||
# ============================================================================
|
||||
|
||||
print_header() {
|
||||
if declare -f df_print_header &>/dev/null; then
|
||||
df_print_header "dotfiles-update"
|
||||
else
|
||||
local user="${USER:-root}"
|
||||
local hostname="${HOSTNAME:-$(hostname -s 2>/dev/null)}"
|
||||
local datetime=$(date '+%a %b %d %H:%M')
|
||||
local hline="" && for ((i=0; i<WIDTH; i++)); do hline+="═"; done
|
||||
|
||||
echo ""
|
||||
echo -e "${DF_GREY}╒${hline}╕${DF_NC}"
|
||||
echo -e "${DF_GREY}│${DF_NC} ${DF_BOLD}${DF_LIGHT_BLUE}✦ ${user}@${hostname}${DF_NC} ${DF_LIGHT_GREEN}dotfiles-update${DF_NC} ${datetime} ${DF_GREY}│${DF_NC}"
|
||||
echo -e "${DF_GREY}╘${hline}╛${DF_NC}"
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
print_success() { echo -e "${DF_GREEN}✓${DF_NC} $1"; }
|
||||
print_warning() { echo -e "${DF_YELLOW}⚠${DF_NC} $1"; }
|
||||
print_error() { echo -e "${DF_RED}✗${DF_NC} $1"; }
|
||||
print_step() { echo -e "${DF_GREEN}==>${DF_NC} $1"; }
|
||||
|
||||
# ============================================================================
|
||||
# Main
|
||||
# ============================================================================
|
||||
|
||||
print_header
|
||||
df_print_header "dotfiles-update"
|
||||
|
||||
if [ ! -d "$DOTFILES_DIR" ]; then
|
||||
print_error "Dotfiles directory not found: $DOTFILES_DIR"
|
||||
if [[ ! -d "$DOTFILES_HOME" ]]; then
|
||||
df_print_error "Dotfiles directory not found: $DOTFILES_HOME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$DOTFILES_DIR"
|
||||
cd "$DOTFILES_HOME"
|
||||
|
||||
print_step "Updating dotfiles from repository..."
|
||||
git pull origin "$DOTFILES_BRANCH"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_success "Dotfiles updated successfully"
|
||||
df_print_step "Updating dotfiles from repository..."
|
||||
|
||||
if git pull origin "${DOTFILES_BRANCH:-main}"; then
|
||||
df_print_success "Dotfiles updated successfully"
|
||||
|
||||
if [[ "$PULL_ONLY" == true ]]; then
|
||||
echo
|
||||
print_success "Pull complete (--pull-only mode)"
|
||||
echo ""
|
||||
df_print_success "Pull complete (--pull-only mode)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo
|
||||
print_success "Update complete!"
|
||||
|
||||
echo ""
|
||||
df_print_success "Update complete!"
|
||||
echo -e "Reload your shell: ${DF_CYAN}reload${DF_NC} or ${DF_CYAN}source ~/.zshrc${DF_NC}"
|
||||
else
|
||||
print_error "Failed to update dotfiles"
|
||||
df_print_error "Failed to update dotfiles"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user