Centralized dotfiles.conf, revamped stuff.

This commit is contained in:
Aaron D. Lee
2025-12-14 15:51:49 -05:00
parent fece4e7d3e
commit 5a82f9046b
8 changed files with 505 additions and 506 deletions

19
.editorconfig Normal file
View File

@@ -0,0 +1,19 @@
# EditorConfig - https://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{sh,zsh,bash}]
indent_size = 4
[*.{yml,yaml}]
indent_size = 2
[Makefile]
indent_style = tab

12
.gitignore vendored
View File

@@ -1,4 +1,3 @@
cat > .gitignore << 'EOF'
# OS files # OS files
.DS_Store .DS_Store
Thumbs.db Thumbs.db
@@ -10,10 +9,19 @@ Thumbs.db
# Local machine-specific configs # Local machine-specific configs
*.local *.local
.zshrc.local
# Sensitive information # Sensitive information
.env .env
.env.* .env.*
secrets/ secrets/
EOF
.git-credentials .git-credentials
# Espanso backups
espanso/match/*.backup
# Editor files
*.swp
*.swo
.idea/
.vscode/

View File

@@ -1,71 +1,75 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# ============================================================================ # ============================================================================
# ADLee Theme System-wide Deployment Script (Enhanced) # ADLee Theme System-wide Deployment Script
# ============================================================================ # ============================================================================
# This script deploys the adlee.zsh-theme system-wide via symlinks # Deploys the zsh theme system-wide via symlinks
#
# Usage: # Usage:
# sudo ./deploy-theme-systemwide.sh # Interactive mode # sudo ./deploy-zshtheme-systemwide.sh # Interactive mode
# sudo ./deploy-theme-systemwide.sh --all # All users with TTY # sudo ./deploy-zshtheme-systemwide.sh --all # All users with oh-my-zsh
# sudo ./deploy-theme-systemwide.sh --current # Current user + root only # sudo ./deploy-zshtheme-systemwide.sh --current # Current user + root only
# sudo ./deploy-theme-systemwide.sh --force # Force replace all links # sudo ./deploy-zshtheme-systemwide.sh --status # Show deployment status
# sudo ./deploy-zshtheme-systemwide.sh --force # Force replace existing links
set -euo pipefail set -euo pipefail
# ============================================================================
# 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"
if [[ -f "$DOTFILES_CONF" ]]; then
source "$DOTFILES_CONF"
else
DOTFILES_DIR="$HOME/.dotfiles"
ZSH_THEME_NAME="adlee"
fi
# ============================================================================
# Configuration # Configuration
# ============================================================================
MASTER_THEME_DIR="/usr/local/share/zsh/themes" MASTER_THEME_DIR="/usr/local/share/zsh/themes"
MASTER_THEME_PATH="${MASTER_THEME_DIR}/adlee.zsh-theme" THEME_FILE="${ZSH_THEME_NAME}.zsh-theme"
THEME_NAME="adlee.zsh-theme" MASTER_THEME_PATH="${MASTER_THEME_DIR}/${THEME_FILE}"
SOURCE_THEME="${HOME}/.dotfiles/zsh/themes/${THEME_NAME}" SOURCE_THEME="${DOTFILES_DIR}/zsh/themes/${THEME_FILE}"
FORCE_REPLACE=false FORCE_REPLACE=false
# Colors for output # Colors
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
RED='\033[0;31m' RED='\033[0;31m'
BLUE='\033[0;34m' BLUE='\033[0;34m'
CYAN='\033[0;36m' CYAN='\033[0;36m'
NC='\033[0m' # No Color NC='\033[0m'
# ============================================================================ # ============================================================================
# Helper Functions # Helper Functions
# ============================================================================ # ============================================================================
print_success() { print_success() { echo -e "${GREEN}${NC} $1"; }
echo -e "${GREEN}${NC} $1" print_warning() { echo -e "${YELLOW}${NC} $1"; }
} print_error() { echo -e "${RED}${NC} $1"; }
print_info() { echo -e "${CYAN}${NC} $1"; }
print_warning() { print_step() { echo -e "\n${GREEN}==>${NC} $1"; }
echo -e "${YELLOW}${NC} $1"
}
print_error() {
echo -e "${RED}${NC} $1"
}
print_info() {
echo -e "${CYAN}${NC} $1"
}
print_step() {
echo -e "\n${GREEN}==>${NC} $1"
}
print_header() { print_header() {
echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════╗${NC}" echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}${NC} ADLee Theme System-wide Deployment ${BLUE}${NC}" echo -e "${BLUE}${NC} ${ZSH_THEME_NAME} Theme System-wide Deployment ${BLUE}${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}\n" echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}\n"
} }
# Check if running as root
check_root() { check_root() {
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
print_error "This script must be run as root (use sudo)" print_error "This script must be run as root (use sudo)"
echo "Usage: sudo $0 [--all|--current]" echo "Usage: sudo $0 [--all|--current|--status]"
exit 1 exit 1
fi fi
} }
# Ask yes/no question
ask_yes_no() { ask_yes_no() {
local prompt="$1" local prompt="$1"
local default="${2:-y}" local default="${2:-y}"
@@ -78,17 +82,14 @@ ask_yes_no() {
read -p "$prompt" response read -p "$prompt" response
response=${response:-$default} response=${response:-$default}
[[ "$response" =~ ^[Yy]$ ]] [[ "$response" =~ ^[Yy]$ ]]
} }
# Check if a path is a symlink pointing to master theme
is_system_symlink() { is_system_symlink() {
local path="$1" local path="$1"
[[ -L "$path" ]] && [[ "$(readlink -f "$path")" == "$MASTER_THEME_PATH" ]] [[ -L "$path" ]] && [[ "$(readlink -f "$path")" == "$MASTER_THEME_PATH" ]]
} }
# Check if a path is a local symlink (from dotfiles)
is_local_symlink() { is_local_symlink() {
local path="$1" local path="$1"
if [[ -L "$path" ]]; then if [[ -L "$path" ]]; then
@@ -99,13 +100,6 @@ is_local_symlink() {
fi fi
} }
# Check if a path is a regular file
is_regular_file() {
local path="$1"
[[ -f "$path" ]] && [[ ! -L "$path" ]]
}
# Get link status description
get_link_status() { get_link_status() {
local path="$1" local path="$1"
@@ -115,7 +109,7 @@ get_link_status() {
echo "system_link" echo "system_link"
elif is_local_symlink "$path"; then elif is_local_symlink "$path"; then
echo "local_link" echo "local_link"
elif is_regular_file "$path"; then elif [[ -f "$path" ]] && [[ ! -L "$path" ]]; then
echo "regular_file" echo "regular_file"
elif [[ -L "$path" ]]; then elif [[ -L "$path" ]]; then
echo "other_link" echo "other_link"
@@ -125,93 +119,58 @@ get_link_status() {
} }
# ============================================================================ # ============================================================================
# Master Theme Setup # Setup Functions
# ============================================================================ # ============================================================================
setup_master_location() { setup_master_location() {
print_step "Setting up master theme location" print_step "Setting up master theme location"
# Create directory if it doesn't exist [[ ! -d "$MASTER_THEME_DIR" ]] && mkdir -p "$MASTER_THEME_DIR" && print_success "Created: $MASTER_THEME_DIR"
if [[ ! -d "$MASTER_THEME_DIR" ]]; then
mkdir -p "$MASTER_THEME_DIR"
print_success "Created directory: $MASTER_THEME_DIR"
fi
# Determine source file
local source_file="" local source_file=""
[[ -f "$SOURCE_THEME" ]] && source_file="$SOURCE_THEME"
[[ -z "$source_file" && -f "$THEME_FILE" ]] && source_file="$THEME_FILE"
[[ -z "$source_file" && -f "$HOME/.oh-my-zsh/themes/$THEME_FILE" ]] && source_file="$HOME/.oh-my-zsh/themes/$THEME_FILE"
if [[ -f "$SOURCE_THEME" ]]; then
source_file="$SOURCE_THEME"
elif [[ -f "$THEME_NAME" ]]; then
source_file="$THEME_NAME"
elif [[ -f "$HOME/.oh-my-zsh/themes/$THEME_NAME" ]]; then
source_file="$HOME/.oh-my-zsh/themes/$THEME_NAME"
fi
# Copy or verify master theme
if [[ -f "$MASTER_THEME_PATH" ]]; then if [[ -f "$MASTER_THEME_PATH" ]]; then
print_info "Master theme already exists: $MASTER_THEME_PATH" print_info "Master theme exists: $MASTER_THEME_PATH"
if [[ -n "$source_file" ]] && ! diff -q "$source_file" "$MASTER_THEME_PATH" &>/dev/null; then
if [[ -n "$source_file" ]]; then print_warning "Source differs from master"
# Check if update is needed if ask_yes_no "Update master theme?"; then
if ! diff -q "$source_file" "$MASTER_THEME_PATH" &>/dev/null; then
print_warning "Source theme differs from master"
if ask_yes_no "Update master theme from source?"; then
cp "$source_file" "$MASTER_THEME_PATH" cp "$source_file" "$MASTER_THEME_PATH"
chmod 644 "$MASTER_THEME_PATH" chmod 644 "$MASTER_THEME_PATH"
print_success "Master theme updated" print_success "Master theme updated"
fi fi
else
print_success "Master theme is up to date"
fi
fi fi
else else
if [[ -z "$source_file" ]]; then if [[ -z "$source_file" ]]; then
print_error "Theme file not found. Please ensure $THEME_NAME exists in:" print_error "Theme file not found. Check these locations:"
echo " - $SOURCE_THEME" echo " - $SOURCE_THEME"
echo " - ./$THEME_NAME" echo " - ./$THEME_FILE"
echo " - ~/.oh-my-zsh/themes/$THEME_NAME"
exit 1 exit 1
fi fi
cp "$source_file" "$MASTER_THEME_PATH" cp "$source_file" "$MASTER_THEME_PATH"
chmod 644 "$MASTER_THEME_PATH" chmod 644 "$MASTER_THEME_PATH"
print_success "Copied theme to master location" print_success "Copied theme to master location"
fi fi
} }
# ============================================================================
# User Detection and Selection
# ============================================================================
get_users_with_tty() { get_users_with_tty() {
local users=() local users=()
[[ -d "/root/.oh-my-zsh" ]] && users+=("root")
# Add root if oh-my-zsh is installed while IFS=: read -r username _ uid _ _ home_dir _; do
if [[ -d "/root/.oh-my-zsh" ]]; then
users+=("root")
fi
# Find regular users with oh-my-zsh
while IFS=: read -r username _ uid _ _ home_dir shell; do
# Skip system users (UID < 1000)
[[ $uid -lt 1000 ]] && continue [[ $uid -lt 1000 ]] && continue
[[ -d "$home_dir/.oh-my-zsh" ]] && users+=("$username")
# Check if user has oh-my-zsh
if [[ -d "$home_dir/.oh-my-zsh" ]]; then
users+=("$username")
fi
done < /etc/passwd done < /etc/passwd
echo "${users[@]}" echo "${users[@]}"
} }
get_current_user() { get_current_user() {
# Get the user who invoked sudo
if [[ -n "${SUDO_USER:-}" ]]; then if [[ -n "${SUDO_USER:-}" ]]; then
echo "$SUDO_USER" echo "$SUDO_USER"
else else
# Fallback to first non-root user with oh-my-zsh
while IFS=: read -r username _ uid _ _ home_dir _; do while IFS=: read -r username _ uid _ _ home_dir _; do
if [[ $uid -ge 1000 ]] && [[ -d "$home_dir/.oh-my-zsh" ]]; then if [[ $uid -ge 1000 ]] && [[ -d "$home_dir/.oh-my-zsh" ]]; then
echo "$username" echo "$username"
@@ -231,22 +190,14 @@ select_users() {
;; ;;
current) current)
local current_user=$(get_current_user) local current_user=$(get_current_user)
if [[ -n "$current_user" ]]; then [[ -n "$current_user" ]] && users=("$current_user")
users=("$current_user") [[ -d "/root/.oh-my-zsh" ]] && users+=("root")
fi
if [[ -d "/root/.oh-my-zsh" ]]; then
users+=("root")
fi
;; ;;
interactive) interactive)
local all_users=($(get_users_with_tty)) local all_users=($(get_users_with_tty))
[[ ${#all_users[@]} -eq 0 ]] && { print_error "No users with oh-my-zsh found"; exit 1; }
if [[ ${#all_users[@]} -eq 0 ]]; then echo "Users with oh-my-zsh:"
print_error "No users with oh-my-zsh found"
exit 1
fi
echo "Users with oh-my-zsh detected:"
for i in "${!all_users[@]}"; do for i in "${!all_users[@]}"; do
echo " $((i+1)). ${all_users[$i]}" echo " $((i+1)). ${all_users[$i]}"
done done
@@ -256,16 +207,8 @@ select_users() {
users=("${all_users[@]}") users=("${all_users[@]}")
else else
local current_user=$(get_current_user) local current_user=$(get_current_user)
if [[ -n "$current_user" ]]; then [[ -n "$current_user" ]] && users=("$current_user") && print_info "Selected: $current_user"
users=("$current_user") [[ -d "/root/.oh-my-zsh" ]] && ask_yes_no "Include root?" && users+=("root")
print_info "Selected: $current_user"
fi
if [[ -d "/root/.oh-my-zsh" ]]; then
if ask_yes_no "Include root user?"; then
users+=("root")
fi
fi
fi fi
;; ;;
esac esac
@@ -273,322 +216,130 @@ select_users() {
echo "${users[@]}" echo "${users[@]}"
} }
# ============================================================================
# Deployment Functions
# ============================================================================
analyze_user_theme() {
local username="$1"
local home_dir
if [[ "$username" == "root" ]]; then
home_dir="/root"
else
home_dir=$(eval echo "~$username")
fi
local theme_path="$home_dir/.oh-my-zsh/themes/$THEME_NAME"
local status=$(get_link_status "$theme_path")
echo "$status"
}
deploy_for_user() { deploy_for_user() {
local username="$1" local username="$1"
local home_dir local home_dir=$([[ "$username" == "root" ]] && echo "/root" || eval echo "~$username")
# Get home directory [[ ! -d "$home_dir" ]] && { print_warning "Home not found: $username"; return 1; }
if [[ "$username" == "root" ]]; then [[ ! -d "$home_dir/.oh-my-zsh" ]] && { print_warning "oh-my-zsh not installed: $username"; return 1; }
home_dir="/root"
else
home_dir=$(eval echo "~$username")
fi
# Check if user's home directory exists local theme_link="$home_dir/.oh-my-zsh/themes/$THEME_FILE"
if [[ ! -d "$home_dir" ]]; then
print_warning "Home directory not found for user: $username"
return 1
fi
local oh_my_zsh_themes="$home_dir/.oh-my-zsh/themes"
local theme_link="$oh_my_zsh_themes/$THEME_NAME"
# Check if oh-my-zsh is installed
if [[ ! -d "$home_dir/.oh-my-zsh" ]]; then
print_warning "oh-my-zsh not installed for user: $username"
return 1
fi
# Analyze current status
local status=$(get_link_status "$theme_link") local status=$(get_link_status "$theme_link")
case "$status" in case "$status" in
system_link) system_link)
if [[ "$FORCE_REPLACE" == true ]]; then [[ "$FORCE_REPLACE" != true ]] && { print_success "Already system-wide: $username"; return 0; }
print_info "Recreating system-wide link for: $username" print_info "Recreating link: $username"
else
print_success "✓ Already using system-wide theme: $username"
return 0
fi
;;
local_link)
print_info "Converting local symlink → system-wide for: $username"
;;
regular_file)
print_warning "Replacing regular file → system-wide for: $username"
;;
other_link)
print_warning "Replacing unknown symlink → system-wide for: $username"
;;
not_present)
print_info "Creating new system-wide link for: $username"
;; ;;
local_link) print_info "Converting local → system: $username" ;;
regular_file) print_warning "Replacing file → system: $username" ;;
*) print_info "Creating link: $username" ;;
esac esac
# Create themes directory if it doesn't exist mkdir -p "$home_dir/.oh-my-zsh/themes"
if [[ ! -d "$oh_my_zsh_themes" ]]; then
mkdir -p "$oh_my_zsh_themes"
if [[ "$username" != "root" ]]; then
chown "$username:$(id -gn "$username" 2>/dev/null || echo "$username")" "$oh_my_zsh_themes"
fi
fi
# Remove existing file/link (this is the key fix!)
if [[ -e "$theme_link" ]] || [[ -L "$theme_link" ]]; then
rm -f "$theme_link" rm -f "$theme_link"
fi
# Create symlink to master theme
ln -sf "$MASTER_THEME_PATH" "$theme_link" ln -sf "$MASTER_THEME_PATH" "$theme_link"
# Fix ownership [[ "$username" != "root" ]] && chown -h "$username:$(id -gn "$username" 2>/dev/null || echo "$username")" "$theme_link" 2>/dev/null || true
if [[ "$username" != "root" ]]; then
chown -h "$username:$(id -gn "$username" 2>/dev/null || echo "$username")" "$theme_link" 2>/dev/null || true
fi
# Verify the symlink was created correctly is_system_symlink "$theme_link" && print_success "Deployed: $username" || { print_error "Failed: $username"; return 1; }
if is_system_symlink "$theme_link"; then
print_success "✓ Deployed system-wide theme for: $username"
else
print_error "✗ Failed to create system-wide link for: $username"
return 1
fi
} }
# ============================================================================
# Status and Reporting
# ============================================================================
show_deployment_status() { show_deployment_status() {
print_step "Current deployment status" print_step "Deployment status"
local users=($(get_users_with_tty)) local users=($(get_users_with_tty))
[[ ${#users[@]} -eq 0 ]] && { print_warning "No users with oh-my-zsh"; return; }
if [[ ${#users[@]} -eq 0 ]]; then
print_warning "No users with oh-my-zsh found"
return
fi
echo echo
printf "%-20s %-20s %s\n" "User" "Status" "Details" printf "%-20s %-20s %s\n" "User" "Status" "Details"
printf "%-20s %-20s %s\n" "----" "------" "-------" printf "%-20s %-20s %s\n" "----" "------" "-------"
for user in "${users[@]}"; do for user in "${users[@]}"; do
local status=$(analyze_user_theme "$user") local home_dir=$([[ "$user" == "root" ]] && echo "/root" || eval echo "~$user")
local home_dir local theme_path="$home_dir/.oh-my-zsh/themes/$THEME_FILE"
local status=$(get_link_status "$theme_path")
if [[ "$user" == "root" ]]; then
home_dir="/root"
else
home_dir=$(eval echo "~$user")
fi
local theme_path="$home_dir/.oh-my-zsh/themes/$THEME_NAME"
case "$status" in case "$status" in
system_link) system_link) printf "%-20s ${GREEN}%-20s${NC} %s\n" "$user" "System-wide ✓" "$MASTER_THEME_PATH" ;;
printf "%-20s ${GREEN}%-20s${NC} %s\n" "$user" "System-wide ✓" "$MASTER_THEME_PATH" local_link) printf "%-20s ${YELLOW}%-20s${NC} %s\n" "$user" "Local symlink" "$(readlink "$theme_path")" ;;
;; regular_file) printf "%-20s ${CYAN}%-20s${NC} %s\n" "$user" "Regular file" "(standalone)" ;;
local_link) not_present) printf "%-20s ${RED}%-20s${NC}\n" "$user" "Not installed" ;;
local target=$(readlink "$theme_path") *) printf "%-20s ${RED}%-20s${NC}\n" "$user" "Unknown" ;;
printf "%-20s ${YELLOW}%-20s${NC} %s\n" "$user" "Local symlink" "$target"
;;
regular_file)
printf "%-20s ${CYAN}%-20s${NC} %s\n" "$user" "Regular file" "(standalone copy)"
;;
other_link)
local target=$(readlink "$theme_path" 2>/dev/null || echo "broken")
printf "%-20s ${YELLOW}%-20s${NC} %s\n" "$user" "Other symlink" "$target"
;;
not_present)
printf "%-20s ${RED}%-20s${NC} %s\n" "$user" "Not installed" ""
;;
*)
printf "%-20s ${RED}%-20s${NC} %s\n" "$user" "Unknown" ""
;;
esac esac
done done
echo echo
} }
# ============================================================================
# Main Execution
# ============================================================================
show_summary() { show_summary() {
echo echo
echo "============================================================================" echo "============================================================================"
echo "Deployment Summary" echo "Master theme: $MASTER_THEME_PATH"
echo "============================================================================"
echo "Master theme location: $MASTER_THEME_PATH"
echo echo
echo "To update the theme in the future:" echo "To update theme globally:"
echo " 1. Edit: $MASTER_THEME_PATH" echo " sudo cp $SOURCE_THEME $MASTER_THEME_PATH"
echo " 2. All users will get updates automatically (via symlinks)"
echo echo
echo "Alternatively, update from your dotfiles:" echo "Check status: sudo $0 --status"
echo " sudo cp ~/.dotfiles/zsh/themes/$THEME_NAME $MASTER_THEME_PATH"
echo
echo "To check deployment status:"
echo " sudo $0 --status"
echo "============================================================================" echo "============================================================================"
} }
# ============================================================================
# Main
# ============================================================================
main() { main() {
local mode="interactive" local mode="interactive"
local status_only=false local status_only=false
# Parse arguments
for arg in "$@"; do for arg in "$@"; do
case "$arg" in case "$arg" in
--all) --all) mode="all" ;;
mode="all" --current) mode="current" ;;
;; --force) FORCE_REPLACE=true ;;
--current) --status|-s) status_only=true ;;
mode="current"
;;
--force)
FORCE_REPLACE=true
;;
--status|-s)
status_only=true
;;
--help|-h) --help|-h)
echo "Usage: sudo $0 [OPTIONS]" echo "Usage: sudo $0 [OPTIONS]"
echo echo
echo "Options:" echo "Options:"
echo " --all Deploy to all users with oh-my-zsh" echo " --all Deploy to all users with oh-my-zsh"
echo " --current Deploy to current user and root only" echo " --current Deploy to current user and root"
echo " --force Force replacement even if system-wide link exists" echo " --force Force replacement of existing links"
echo " --status Show current deployment status" echo " --status Show current deployment status"
echo " --help Show this help message" echo " --help Show this help"
echo
echo "Examples:"
echo " sudo $0 # Interactive mode"
echo " sudo $0 --all # Deploy to all users"
echo " sudo $0 --current --force # Force update for current user + root"
echo
exit 0 exit 0
;; ;;
*) *) print_error "Unknown option: $arg"; exit 1 ;;
print_error "Unknown option: $arg"
echo "Use --help for usage information"
exit 1
;;
esac esac
done done
print_header print_header
check_root check_root
# Status only mode
if [[ "$status_only" == true ]]; then if [[ "$status_only" == true ]]; then
show_deployment_status show_deployment_status
exit 0 exit 0
fi fi
# Show current status first
show_deployment_status show_deployment_status
# Setup master location
setup_master_location setup_master_location
# Select users
local users=($(select_users "$mode")) local users=($(select_users "$mode"))
[[ ${#users[@]} -eq 0 ]] && { print_error "No users selected"; exit 1; }
if [[ ${#users[@]} -eq 0 ]]; then
print_error "No users selected for deployment"
exit 1
fi
# Print info about selected mode
case "$mode" in
all)
print_info "Deploying to all users with oh-my-zsh"
;;
current)
print_info "Deploying to current user and root"
;;
esac
echo
print_step "Deploying to ${#users[@]} user(s): ${users[*]}" print_step "Deploying to ${#users[@]} user(s): ${users[*]}"
[[ "$FORCE_REPLACE" == true ]] && print_warning "Force mode enabled"
if [[ "$FORCE_REPLACE" == true ]]; then ask_yes_no "Proceed?" || { print_warning "Cancelled"; exit 0; }
print_warning "Force mode: will replace ALL existing links"
fi
echo echo
local ok=0 fail=0
# Interactive confirmation for converting local links
if [[ "$mode" == "interactive" ]]; then
local has_local_links=false
for user in "${users[@]}"; do for user in "${users[@]}"; do
local status=$(analyze_user_theme "$user") deploy_for_user "$user" && ((ok++)) || ((fail++))
if [[ "$status" == "local_link" ]]; then
has_local_links=true
break
fi
done
if [[ "$has_local_links" == true ]]; then
echo "⚠ Some users have local dotfiles symlinks."
echo "This will replace them with system-wide symlinks pointing to:"
echo " $MASTER_THEME_PATH"
echo
if ! ask_yes_no "Convert local symlinks to system-wide?"; then
print_warning "Deployment cancelled"
exit 0
fi
fi
fi
if ! ask_yes_no "Proceed with deployment?"; then
print_warning "Deployment cancelled"
exit 0
fi
# Deploy to each user
echo
local deployed_count=0
local failed_count=0
for user in "${users[@]}"; do
if deploy_for_user "$user"; then
((deployed_count++))
else
((failed_count++))
fi
done done
echo echo
if [[ $failed_count -eq 0 ]]; then [[ $fail -eq 0 ]] && print_success "Complete! ($ok/${#users[@]})" || print_warning "Done with errors ($ok ok, $fail failed)"
print_success "Deployment complete! ($deployed_count/${#users[@]} users)"
else
print_warning "Deployment finished with errors ($deployed_count succeeded, $failed_count failed)"
fi
# Show updated status
echo
show_deployment_status show_deployment_status
show_summary show_summary
} }

View File

@@ -2,10 +2,32 @@
# ============================================================================ # ============================================================================
# Espanso Setup and Configuration Script # Espanso Setup and Configuration Script
# ============================================================================ # ============================================================================
# This script helps set up espanso with custom configurations
set -e set -e
# ============================================================================
# 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"
if [[ -f "$DOTFILES_CONF" ]]; then
source "$DOTFILES_CONF"
else
DOTFILES_DIR="$HOME/.dotfiles"
USER_FULLNAME=""
USER_EMAIL=""
USER_PHONE=""
USER_WEBSITE=""
USER_GITHUB=""
fi
# ============================================================================
# Colors
# ============================================================================
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
BLUE='\033[0;34m' BLUE='\033[0;34m'
@@ -46,10 +68,13 @@ ask_yes_no() {
read -p "$prompt" response read -p "$prompt" response
response=${response:-$default} response=${response:-$default}
[[ "$response" =~ ^[Yy]$ ]] [[ "$response" =~ ^[Yy]$ ]]
} }
# ============================================================================
# Functions
# ============================================================================
check_espanso() { check_espanso() {
if ! command -v espanso &> /dev/null; then if ! command -v espanso &> /dev/null; then
print_error "espanso is not installed" print_error "espanso is not installed"
@@ -80,41 +105,84 @@ personalize_config() {
local personal_file="$HOME/.config/espanso/match/personal.yml" local personal_file="$HOME/.config/espanso/match/personal.yml"
if [ ! -f "$personal_file" ]; then if [ ! -f "$personal_file" ]; then
print_error "Personal config file not found: $personal_file" print_warning "Personal config file not found, creating from template..."
return 1 mkdir -p "$(dirname "$personal_file")"
cat > "$personal_file" << 'EOF'
# ============================================================================
# Personal Espanso Snippets
# ============================================================================
# Edit these with your own information
matches:
# Personal info
- trigger: "..myemail"
replace: "your.email@example.com"
- trigger: "..myname"
replace: "Your Full Name"
- trigger: "..myphone"
replace: "+1 (555) 123-4567"
- trigger: "..myweb"
replace: "https://yourwebsite.com"
- trigger: "..mygithub"
replace: "https://github.com/yourusername"
# Email signature
- trigger: "..sig"
replace: |
Best regards,
Your Full Name
your.email@example.com
# Address (customize as needed)
- trigger: "..myaddr"
replace: |
123 Main Street
City, ST 12345
EOF
print_success "Created personal.yml template"
fi fi
echo echo
echo "Let's personalize your espanso configuration!" echo "Let's personalize your espanso configuration!"
echo "(Press Enter to keep existing/default values)"
echo echo
read -p "Your full name: " fullname # Use config values as defaults, prompt for any missing
read -p "Your email: " email local fullname="${USER_FULLNAME}"
read -p "Your phone (optional): " phone local email="${USER_EMAIL}"
read -p "Your website (optional): " website local phone="${USER_PHONE}"
read -p "Your GitHub username (optional): " github local website="${USER_WEBSITE}"
local github="${USER_GITHUB}"
# Create a backup [[ -z "$fullname" ]] && read -p "Your full name: " fullname
[[ -z "$email" ]] && read -p "Your email: " email
[[ -z "$phone" ]] && read -p "Your phone (optional): " phone
[[ -z "$website" ]] && read -p "Your website (optional): " website
[[ -z "$github" ]] && read -p "Your GitHub username (optional): " github
# Create backup
cp "$personal_file" "$personal_file.backup" cp "$personal_file" "$personal_file.backup"
# Update the personal.yml file # Update values
sed -i "s/your.email@example.com/$email/g" "$personal_file" [[ -n "$email" ]] && sed -i "s/your.email@example.com/$email/g" "$personal_file"
sed -i "s/Your Full Name/$fullname/g" "$personal_file" [[ -n "$fullname" ]] && sed -i "s/Your Full Name/$fullname/g" "$personal_file"
[[ -n "$phone" ]] && sed -i "s/+1 (555) 123-4567/$phone/g" "$personal_file"
if [ -n "$phone" ]; then [[ -n "$website" ]] && sed -i "s|https://yourwebsite.com|$website|g" "$personal_file"
sed -i "s/+1 (555) 123-4567/$phone/g" "$personal_file" [[ -n "$github" ]] && sed -i "s/yourusername/$github/g" "$personal_file"
fi
if [ -n "$website" ]; then
sed -i "s|https://yourwebsite.com|$website|g" "$personal_file"
fi
if [ -n "$github" ]; then
sed -i "s/yourusername/$github/g" "$personal_file"
fi
print_success "Personal configuration updated!" print_success "Personal configuration updated!"
print_warning "Backup saved to: $personal_file.backup" print_warning "Backup saved to: $personal_file.backup"
# Suggest updating dotfiles.conf for future installs
echo
echo -e "${BLUE}Tip:${NC} Add these to dotfiles.conf for future installs:"
echo " USER_FULLNAME=\"$fullname\""
echo " USER_EMAIL=\"$email\""
[[ -n "$github" ]] && echo " USER_GITHUB=\"$github\""
} }
install_packages() { install_packages() {
@@ -125,8 +193,6 @@ install_packages() {
echo " 1. emoji - Emoji snippets (e.g., :smile: → 😊)" echo " 1. emoji - Emoji snippets (e.g., :smile: → 😊)"
echo " 2. greek-letters - Greek letters (e.g., :alpha: → α)" echo " 2. greek-letters - Greek letters (e.g., :alpha: → α)"
echo " 3. math - Math symbols (e.g., :sum: → ∑)" echo " 3. math - Math symbols (e.g., :sum: → ∑)"
echo " 4. accents - Accented characters"
echo " 5. all-emojis - Complete emoji collection"
echo echo
if ask_yes_no "Install emoji package?"; then if ask_yes_no "Install emoji package?"; then
@@ -165,47 +231,29 @@ ${YELLOW}Toggle espanso on/off:${NC}
${YELLOW}Open search menu:${NC} ${YELLOW}Open search menu:${NC}
ALT+SPACE ALT+SPACE
${YELLOW}Basic triggers (from base.yml):${NC} ${YELLOW}Basic triggers:${NC}
:date → Current date (YYYY-MM-DD) ..date → Current date (YYYY-MM-DD)
:time → Current time (HH:MM:SS) ..time → Current time (HH:MM:SS)
:datetime → Full datetime ..shrug → ¯\\_(ツ)_/¯
:shrug → ¯\\_(ツ)_/¯ ..gstat → git status
:flip → (╯°□°)╯︵ ┻━┻ ..myemail → Your email
${YELLOW}Code snippets:${NC}
:bash → Bash script template
:python → Python script template
:mdcode → Markdown code block
${YELLOW}Git shortcuts:${NC}
:gst → git status
:gco → git checkout
:gcm → git commit -m ""
${YELLOW}Personal (customize in personal.yml):${NC}
:myemail → Your email
:myname → Your name
:sig → Email signature
${YELLOW}Espanso commands:${NC} ${YELLOW}Espanso commands:${NC}
espanso status - Check if running espanso status - Check if running
espanso restart - Restart service espanso restart - Restart service
espanso edit - Edit config
espanso log - View logs espanso log - View logs
espanso package list - List installed packages
espanso package install X - Install package
${YELLOW}Configuration files:${NC} ${YELLOW}Configuration files:${NC}
~/.config/espanso/config/default.yml - Main config ~/.config/espanso/match/base.yml - Main snippets
~/.config/espanso/match/base.yml - Base snippets ~/.config/espanso/match/personal.yml - Your personal snippets
~/.config/espanso/match/personal.yml - Personal snippets
${GREEN}Create your own snippets!${NC}
Edit the YAML files above to add custom triggers.
EOF EOF
} }
# ============================================================================
# Main
# ============================================================================
main() { main() {
print_header print_header
@@ -231,7 +279,7 @@ main() {
echo echo
print_success "Espanso setup complete!" print_success "Espanso setup complete!"
echo echo
echo "Try typing ${YELLOW}:date${NC} in any application to test it!" echo "Try typing ${YELLOW}..date${NC} in any application to test it!"
} }
main "$@" main "$@"

View File

@@ -6,7 +6,29 @@
set -e set -e
DOTFILES_DIR="$HOME/.dotfiles" # ============================================================================
# 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"
if [[ -f "$DOTFILES_CONF" ]]; then
source "$DOTFILES_CONF"
else
# Fallback defaults
DOTFILES_DIR="$HOME/.dotfiles"
DOTFILES_BRANCH="main"
DOTFILES_GITHUB_USER="adlee-was-taken"
DOTFILES_REPO_NAME="dotfiles"
DOTFILES_RAW_URL="https://raw.githubusercontent.com/${DOTFILES_GITHUB_USER}/${DOTFILES_REPO_NAME}/${DOTFILES_BRANCH}"
fi
# ============================================================================
# Colors
# ============================================================================
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
RED='\033[0;31m' RED='\033[0;31m'
@@ -24,22 +46,25 @@ print_error() {
echo -e "${RED}${NC} $1" echo -e "${RED}${NC} $1"
} }
# ============================================================================
# Main
# ============================================================================
if [ ! -d "$DOTFILES_DIR" ]; then if [ ! -d "$DOTFILES_DIR" ]; then
print_error "Dotfiles directory not found: $DOTFILES_DIR" print_error "Dotfiles directory not found: $DOTFILES_DIR"
echo "Run the installation script first:" echo "Run the installation script first:"
echo " curl -fsSL https://raw.githubusercontent.com/YOUR_USERNAME/dotfiles/main/install.sh | bash" echo " curl -fsSL ${DOTFILES_RAW_URL}/install.sh | bash"
exit 1 exit 1
fi fi
cd "$DOTFILES_DIR" cd "$DOTFILES_DIR"
echo "Updating dotfiles from repository..." echo "Updating dotfiles from repository..."
git pull origin main git pull origin "$DOTFILES_BRANCH"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
print_success "Dotfiles updated successfully" print_success "Dotfiles updated successfully"
# Check if install script exists and run it
if [ -f "$DOTFILES_DIR/install.sh" ]; then if [ -f "$DOTFILES_DIR/install.sh" ]; then
echo echo
read -p "Run install script to update links? [Y/n]: " response read -p "Run install script to update links? [Y/n]: " response

62
dotfiles.conf Normal file
View File

@@ -0,0 +1,62 @@
# ============================================================================
# Dotfiles Configuration
# ============================================================================
# Fork this repo? Update the values below to match your setup.
# All scripts source this file for configuration.
# ============================================================================
# --- GitHub Settings ---
DOTFILES_GITHUB_USER="adlee-was-taken"
DOTFILES_REPO_NAME="dotfiles"
DOTFILES_BRANCH="main"
# --- Local Paths ---
DOTFILES_DIR="$HOME/.dotfiles"
DOTFILES_BACKUP_PREFIX="$HOME/.dotfiles_backup"
# --- User Identity (used by setup-espanso.sh) ---
# Leave blank to be prompted during setup, or pre-fill for automated installs
USER_FULLNAME=""
USER_EMAIL=""
USER_PHONE=""
USER_WEBSITE=""
USER_GITHUB=""
# --- Feature Toggles ---
# Set to "true" or "false" to control what gets installed
INSTALL_ESPANSO="ask" # "true", "false", or "ask"
INSTALL_FZF="ask"
INSTALL_BAT="ask"
INSTALL_EZA="ask"
SET_ZSH_DEFAULT="ask"
# --- Theme Settings ---
ZSH_THEME_NAME="adlee"
THEME_TIMER_THRESHOLD=10 # Show elapsed time for commands longer than N seconds
THEME_PATH_TRUNCATE_LENGTH=32 # Truncate path display after N characters
# --- Espanso Settings ---
ESPANSO_TRIGGER_PREFIX=".." # Prefix for all triggers (e.g., "..date")
# --- Snapper Settings (CachyOS/Arch with btrfs) ---
SNAPPER_CONFIG="root"
LIMINE_CONF="/boot/limine.conf"
# ============================================================================
# Derived URLs (generally don't edit these)
# ============================================================================
DOTFILES_REPO_URL="https://github.com/${DOTFILES_GITHUB_USER}/${DOTFILES_REPO_NAME}.git"
DOTFILES_RAW_URL="https://raw.githubusercontent.com/${DOTFILES_GITHUB_USER}/${DOTFILES_REPO_NAME}/${DOTFILES_BRANCH}"
# ============================================================================
# Helper function to source this config from any script
# ============================================================================
# Add this to scripts that need config values:
#
# SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# DOTFILES_CONF="${SCRIPT_DIR}/dotfiles.conf"
# [[ -f "$DOTFILES_CONF" ]] || DOTFILES_CONF="${SCRIPT_DIR}/../dotfiles.conf"
# [[ -f "$DOTFILES_CONF" ]] || DOTFILES_CONF="$HOME/.dotfiles/dotfiles.conf"
# source "$DOTFILES_CONF" || { echo "Error: Cannot find dotfiles.conf"; exit 1; }
#
# ============================================================================

View File

@@ -1,4 +1,61 @@
# ============================================================================
# Personal Espanso Snippets
# ============================================================================
# Customize these with your own information.
# Run ./bin/setup-espanso.sh to update interactively.
# ============================================================================
matches: matches:
# Simple text replacement # --- Personal Info ---
- trigger: "..me"
replace: "Aaron D. Lee" - trigger: "..myemail"
replace: "your.email@example.com"
- trigger: "..myname"
replace: "Your Full Name"
- trigger: "..myphone"
replace: "+1 (555) 123-4567"
- trigger: "..myweb"
replace: "https://yourwebsite.com"
- trigger: "..mygithub"
replace: "https://github.com/yourusername"
# --- Email Signatures ---
- trigger: "..sig"
replace: |
Best regards,
Your Full Name
your.email@example.com
- trigger: "..sigfull"
replace: |
Best regards,
Your Full Name
your.email@example.com
+1 (555) 123-4567
https://yourwebsite.com
# --- Address ---
- trigger: "..myaddr"
replace: |
123 Main Street
City, ST 12345
USA
# --- Work Info (customize as needed) ---
- trigger: "..workemail"
replace: "your.name@company.com"
- trigger: "..worksig"
replace: |
Best regards,
Your Full Name
Your Title
Company Name
your.name@company.com

View File

@@ -2,25 +2,60 @@
# ============================================================================ # ============================================================================
# ADLee's Dotfiles Installation Script # ADLee's Dotfiles Installation Script
# ============================================================================ # ============================================================================
# Quick install: curl -fsSL https://raw.githubusercontent.com/adlee-was-taken/dotfiles/main/install.sh | bash # Quick install:
# Or: git clone https://github.com/adlee-was-taken/dotfiles.git && cd dotfiles && ./install.sh # curl -fsSL https://raw.githubusercontent.com/adlee-was-taken/dotfiles/main/install.sh | bash
# Or:
# git clone https://github.com/adlee-was-taken/dotfiles.git && cd dotfiles && ./install.sh
#
# Fork this repo? Edit dotfiles.conf with your settings.
# ============================================================================
set -e set -e
# ============================================================================ # ============================================================================
# Configuration # Load Configuration
# ============================================================================ # ============================================================================
DOTFILES_REPO="https://github.com/adlee-was-taken/dotfiles.git" load_config() {
DOTFILES_DIR="$HOME/.dotfiles" local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKUP_DIR="$HOME/.dotfiles_backup_$(date +%Y%m%d_%H%M%S)" local conf_file="${script_dir}/dotfiles.conf"
if [[ -f "$conf_file" ]]; then
source "$conf_file"
else
# Fallback defaults for curl|bash install (before clone)
DOTFILES_GITHUB_USER="${DOTFILES_GITHUB_USER:-adlee-was-taken}"
DOTFILES_REPO_NAME="${DOTFILES_REPO_NAME:-dotfiles}"
DOTFILES_BRANCH="${DOTFILES_BRANCH:-main}"
DOTFILES_DIR="${DOTFILES_DIR:-$HOME/.dotfiles}"
DOTFILES_BACKUP_PREFIX="${DOTFILES_BACKUP_PREFIX:-$HOME/.dotfiles_backup}"
DOTFILES_REPO_URL="https://github.com/${DOTFILES_GITHUB_USER}/${DOTFILES_REPO_NAME}.git"
# Feature toggles
INSTALL_ESPANSO="${INSTALL_ESPANSO:-ask}"
INSTALL_FZF="${INSTALL_FZF:-ask}"
INSTALL_BAT="${INSTALL_BAT:-ask}"
INSTALL_EZA="${INSTALL_EZA:-ask}"
SET_ZSH_DEFAULT="${SET_ZSH_DEFAULT:-ask}"
# Theme settings
ZSH_THEME_NAME="${ZSH_THEME_NAME:-adlee}"
fi
}
load_config
BACKUP_DIR="${DOTFILES_BACKUP_PREFIX}_$(date +%Y%m%d_%H%M%S)"
# ============================================================================
# Colors # Colors
# ============================================================================
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
BLUE='\033[0;34m' BLUE='\033[0;34m'
NC='\033[0m' # No Color NC='\033[0m'
# ============================================================================ # ============================================================================
# Helper Functions # Helper Functions
@@ -28,7 +63,8 @@ NC='\033[0m' # No Color
print_header() { print_header() {
echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════╗${NC}" echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}${NC} ADLee's Dotfiles Installation ${BLUE}${NC}" echo -e "${BLUE}${NC} Dotfiles Installation ${BLUE}${NC}"
echo -e "${BLUE}${NC} Repo: ${DOTFILES_GITHUB_USER}/${DOTFILES_REPO_NAME}${BLUE}${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}\n" echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}\n"
} }
@@ -60,10 +96,28 @@ ask_yes_no() {
read -p "$prompt" response read -p "$prompt" response
response=${response:-$default} response=${response:-$default}
[[ "$response" =~ ^[Yy]$ ]] [[ "$response" =~ ^[Yy]$ ]]
} }
# Check feature toggle setting
should_install() {
local setting="$1"
local name="$2"
case "$setting" in
true|yes|1)
return 0
;;
false|no|0)
return 1
;;
*)
ask_yes_no "Install $name?"
return $?
;;
esac
}
# ============================================================================ # ============================================================================
# Installation Functions # Installation Functions
# ============================================================================ # ============================================================================
@@ -123,13 +177,16 @@ clone_or_update_dotfiles() {
print_warning "Dotfiles directory already exists" print_warning "Dotfiles directory already exists"
if ask_yes_no "Update existing dotfiles?"; then if ask_yes_no "Update existing dotfiles?"; then
cd "$DOTFILES_DIR" cd "$DOTFILES_DIR"
#git pull origin main git pull origin "$DOTFILES_BRANCH"
print_success "Dotfiles updated" print_success "Dotfiles updated"
fi fi
else else
#git clone "$DOTFILES_REPO" "$DOTFILES_DIR" git clone "$DOTFILES_REPO_URL" "$DOTFILES_DIR"
print_success "Dotfiles cloned to $DOTFILES_DIR" print_success "Dotfiles cloned to $DOTFILES_DIR"
fi fi
# Reload config after clone (now we have dotfiles.conf)
load_config
} }
backup_existing_configs() { backup_existing_configs() {
@@ -183,10 +240,10 @@ link_dotfiles() {
print_success "Linked: .zshrc" print_success "Linked: .zshrc"
fi fi
# Link adlee theme # Link theme
if [ -f "$DOTFILES_DIR/zsh/themes/adlee.zsh-theme" ]; then if [ -f "$DOTFILES_DIR/zsh/themes/${ZSH_THEME_NAME}.zsh-theme" ]; then
ln -sf "$DOTFILES_DIR/zsh/themes/adlee.zsh-theme" "$HOME/.oh-my-zsh/themes/adlee.zsh-theme" ln -sf "$DOTFILES_DIR/zsh/themes/${ZSH_THEME_NAME}.zsh-theme" "$HOME/.oh-my-zsh/themes/${ZSH_THEME_NAME}.zsh-theme"
print_success "Linked: adlee.zsh-theme" print_success "Linked: ${ZSH_THEME_NAME}.zsh-theme"
fi fi
# Link gitconfig # Link gitconfig
@@ -224,10 +281,21 @@ set_zsh_default() {
print_step "Setting zsh as default shell" print_step "Setting zsh as default shell"
if [ "$SHELL" != "$(which zsh)" ]; then if [ "$SHELL" != "$(which zsh)" ]; then
case "$SET_ZSH_DEFAULT" in
true|yes|1)
chsh -s "$(which zsh)"
print_success "Default shell changed to zsh (restart required)"
;;
false|no|0)
print_warning "Skipping shell change (disabled in config)"
;;
*)
if ask_yes_no "Set zsh as your default shell?"; then if ask_yes_no "Set zsh as your default shell?"; then
chsh -s "$(which zsh)" chsh -s "$(which zsh)"
print_success "Default shell changed to zsh (restart required)" print_success "Default shell changed to zsh (restart required)"
fi fi
;;
esac
else else
print_success "zsh is already your default shell" print_success "zsh is already your default shell"
fi fi
@@ -243,16 +311,11 @@ install_espanso() {
case "$OS" in case "$OS" in
ubuntu|debian) ubuntu|debian)
# Install required dependencies
sudo apt-get install -y wget sudo apt-get install -y wget
# Download and install espanso
ESPANSO_VERSION="2.2.1" ESPANSO_VERSION="2.2.1"
wget "https://github.com/espanso/espanso/releases/download/v${ESPANSO_VERSION}/espanso-debian-x11-amd64.deb" -O /tmp/espanso.deb wget "https://github.com/espanso/espanso/releases/download/v${ESPANSO_VERSION}/espanso-debian-x11-amd64.deb" -O /tmp/espanso.deb
sudo apt install /tmp/espanso.deb sudo apt install /tmp/espanso.deb
rm /tmp/espanso.deb rm /tmp/espanso.deb
# Register espanso as a systemd service
espanso service register espanso service register
print_success "espanso installed (X11 version)" print_success "espanso installed (X11 version)"
;; ;;
@@ -265,26 +328,18 @@ install_espanso() {
espanso service register espanso service register
print_success "espanso installed" print_success "espanso installed"
;; ;;
arch) arch|cachyos)
# Check if paru is installed, if not try to install it
if ! command -v paru &> /dev/null; then if ! command -v paru &> /dev/null; then
print_warning "paru not found, attempting to install..." print_warning "paru not found, attempting to install..."
# Install dependencies for building paru
sudo pacman -S --needed --noconfirm base-devel git sudo pacman -S --needed --noconfirm base-devel git
# Clone and build paru
cd /tmp cd /tmp
git clone https://aur.archlinux.org/paru.git git clone https://aur.archlinux.org/paru.git
cd paru cd paru
makepkg -si --noconfirm makepkg -si --noconfirm
cd ~ cd ~
rm -rf /tmp/paru rm -rf /tmp/paru
print_success "paru installed" print_success "paru installed"
fi fi
# Install espanso using paru
paru -S --noconfirm espanso-bin paru -S --noconfirm espanso-bin
espanso service register espanso service register
print_success "espanso installed" print_success "espanso installed"
@@ -306,26 +361,17 @@ link_espanso_config() {
print_step "Linking espanso configuration" print_step "Linking espanso configuration"
if [ -d "$DOTFILES_DIR/espanso" ]; then if [ -d "$DOTFILES_DIR/espanso" ]; then
# Backup existing espanso config if it exists and is not a symlink
if [ -d "$HOME/.config/espanso" ] && [ ! -L "$HOME/.config/espanso" ]; then if [ -d "$HOME/.config/espanso" ] && [ ! -L "$HOME/.config/espanso" ]; then
if [ "$backup_needed" = false ]; then
mkdir -p "$BACKUP_DIR" mkdir -p "$BACKUP_DIR"
fi
mv "$HOME/.config/espanso" "$BACKUP_DIR/espanso" mv "$HOME/.config/espanso" "$BACKUP_DIR/espanso"
print_success "Backed up existing espanso config" print_success "Backed up existing espanso config"
fi fi
# Remove old symlink if it exists
[ -L "$HOME/.config/espanso" ] && rm "$HOME/.config/espanso" [ -L "$HOME/.config/espanso" ] && rm "$HOME/.config/espanso"
# Create .config directory if it doesn't exist
mkdir -p "$HOME/.config" mkdir -p "$HOME/.config"
# Create symlink
ln -sf "$DOTFILES_DIR/espanso" "$HOME/.config/espanso" ln -sf "$DOTFILES_DIR/espanso" "$HOME/.config/espanso"
print_success "Linked: espanso config" print_success "Linked: espanso config"
# Restart espanso if it's running
if command -v espanso &> /dev/null; then if command -v espanso &> /dev/null; then
espanso restart 2>/dev/null || true espanso restart 2>/dev/null || true
print_success "Restarted espanso service" print_success "Restarted espanso service"
@@ -338,59 +384,43 @@ link_espanso_config() {
install_optional_tools() { install_optional_tools() {
print_step "Optional tools" print_step "Optional tools"
# espanso - text expander # espanso
if ! command -v espanso &> /dev/null; then if ! command -v espanso &> /dev/null; then
if ask_yes_no "Install espanso (text expander)?"; then if should_install "$INSTALL_ESPANSO" "espanso (text expander)"; then
install_espanso install_espanso
fi fi
fi fi
# fzf - fuzzy finder # fzf
if ! command -v fzf &> /dev/null; then if ! command -v fzf &> /dev/null; then
if ask_yes_no "Install fzf (fuzzy finder)?"; then if should_install "$INSTALL_FZF" "fzf (fuzzy finder)"; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install --all ~/.fzf/install --all
print_success "fzf installed" print_success "fzf installed"
fi fi
fi fi
# bat - better cat # bat
if ! command -v bat &> /dev/null && ! command -v batcat &> /dev/null; then if ! command -v bat &> /dev/null && ! command -v batcat &> /dev/null; then
if ask_yes_no "Install bat (better cat)?"; then if should_install "$INSTALL_BAT" "bat (better cat)"; then
case "$OS" in case "$OS" in
ubuntu|debian) ubuntu|debian) sudo apt-get install -y bat ;;
sudo apt-get install -y bat fedora|rhel|centos) sudo dnf install -y bat ;;
;; arch|cachyos) sudo pacman -S --noconfirm bat ;;
fedora|rhel|centos) macos) brew install bat ;;
sudo dnf install -y bat
;;
arch)
sudo pacman -S --noconfirm bat
;;
macos)
brew install bat
;;
esac esac
print_success "bat installed" print_success "bat installed"
fi fi
fi fi
# eza - better ls # eza
if ! command -v eza &> /dev/null; then if ! command -v eza &> /dev/null; then
if ask_yes_no "Install eza (better ls)?"; then if should_install "$INSTALL_EZA" "eza (better ls)"; then
case "$OS" in case "$OS" in
ubuntu|debian) ubuntu|debian) sudo apt-get install -y eza ;;
sudo apt-get install -y eza fedora|rhel|centos) sudo dnf install -y eza ;;
;; arch|cachyos) sudo pacman -S --noconfirm eza ;;
fedora|rhel|centos) macos) brew install eza ;;
sudo dnf install -y eza
;;
arch)
sudo pacman -S --noconfirm eza
;;
macos)
brew install eza
;;
esac esac
print_success "eza installed" print_success "eza installed"
fi fi
@@ -398,7 +428,7 @@ install_optional_tools() {
} }
# ============================================================================ # ============================================================================
# Main Installation Flow # Main
# ============================================================================ # ============================================================================
main() { main() {
@@ -422,7 +452,7 @@ main() {
echo -e "${BLUE}Next steps:${NC}" echo -e "${BLUE}Next steps:${NC}"
echo " 1. Restart your terminal or run: exec zsh" echo " 1. Restart your terminal or run: exec zsh"
echo " 2. Your old configs are backed up in: $BACKUP_DIR" echo " 2. Your old configs are backed up in: $BACKUP_DIR"
echo " 3. Customize ~/.zshrc as needed" echo " 3. Customize settings in: $DOTFILES_DIR/dotfiles.conf"
echo echo
echo -e "${BLUE}To update dotfiles in the future:${NC}" echo -e "${BLUE}To update dotfiles in the future:${NC}"
echo " cd ~/.dotfiles && git pull && ./install.sh" echo " cd ~/.dotfiles && git pull && ./install.sh"
@@ -433,5 +463,4 @@ main() {
fi fi
} }
# Run main function
main "$@" main "$@"