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
.DS_Store
Thumbs.db
@@ -10,10 +9,19 @@ Thumbs.db
# Local machine-specific configs
*.local
.zshrc.local
# Sensitive information
.env
.env.*
secrets/
EOF
.git-credentials
# Espanso backups
espanso/match/*.backup
# Editor files
*.swp
*.swo
.idea/
.vscode/

View File

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

View File

@@ -2,10 +2,32 @@
# ============================================================================
# Espanso Setup and Configuration Script
# ============================================================================
# This script helps set up espanso with custom configurations
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'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
@@ -46,10 +68,13 @@ ask_yes_no() {
read -p "$prompt" response
response=${response:-$default}
[[ "$response" =~ ^[Yy]$ ]]
}
# ============================================================================
# Functions
# ============================================================================
check_espanso() {
if ! command -v espanso &> /dev/null; then
print_error "espanso is not installed"
@@ -80,41 +105,84 @@ personalize_config() {
local personal_file="$HOME/.config/espanso/match/personal.yml"
if [ ! -f "$personal_file" ]; then
print_error "Personal config file not found: $personal_file"
return 1
print_warning "Personal config file not found, creating from template..."
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
echo
echo "Let's personalize your espanso configuration!"
echo "(Press Enter to keep existing/default values)"
echo
read -p "Your full name: " fullname
read -p "Your email: " email
read -p "Your phone (optional): " phone
read -p "Your website (optional): " website
read -p "Your GitHub username (optional): " github
# Use config values as defaults, prompt for any missing
local fullname="${USER_FULLNAME}"
local email="${USER_EMAIL}"
local phone="${USER_PHONE}"
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"
# Update the personal.yml file
sed -i "s/your.email@example.com/$email/g" "$personal_file"
sed -i "s/Your Full Name/$fullname/g" "$personal_file"
if [ -n "$phone" ]; then
sed -i "s/+1 (555) 123-4567/$phone/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
# Update values
[[ -n "$email" ]] && sed -i "s/your.email@example.com/$email/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"
[[ -n "$website" ]] && sed -i "s|https://yourwebsite.com|$website|g" "$personal_file"
[[ -n "$github" ]] && sed -i "s/yourusername/$github/g" "$personal_file"
print_success "Personal configuration updated!"
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() {
@@ -125,8 +193,6 @@ install_packages() {
echo " 1. emoji - Emoji snippets (e.g., :smile: → 😊)"
echo " 2. greek-letters - Greek letters (e.g., :alpha: → α)"
echo " 3. math - Math symbols (e.g., :sum: → ∑)"
echo " 4. accents - Accented characters"
echo " 5. all-emojis - Complete emoji collection"
echo
if ask_yes_no "Install emoji package?"; then
@@ -165,47 +231,29 @@ ${YELLOW}Toggle espanso on/off:${NC}
${YELLOW}Open search menu:${NC}
ALT+SPACE
${YELLOW}Basic triggers (from base.yml):${NC}
:date → Current date (YYYY-MM-DD)
:time → Current time (HH:MM:SS)
:datetime → Full datetime
:shrug → ¯\\_(ツ)_/¯
:flip → (╯°□°)╯︵ ┻━┻
${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}Basic triggers:${NC}
..date → Current date (YYYY-MM-DD)
..time → Current time (HH:MM:SS)
..shrug → ¯\\_(ツ)_/¯
..gstat → git status
..myemail → Your email
${YELLOW}Espanso commands:${NC}
espanso status - Check if running
espanso restart - Restart service
espanso edit - Edit config
espanso log - View logs
espanso package list - List installed packages
espanso package install X - Install package
espanso status - Check if running
espanso restart - Restart service
espanso log - View logs
${YELLOW}Configuration files:${NC}
~/.config/espanso/config/default.yml - Main config
~/.config/espanso/match/base.yml - Base snippets
~/.config/espanso/match/personal.yml - Personal snippets
${GREEN}Create your own snippets!${NC}
Edit the YAML files above to add custom triggers.
~/.config/espanso/match/base.yml - Main snippets
~/.config/espanso/match/personal.yml - Your personal snippets
EOF
}
# ============================================================================
# Main
# ============================================================================
main() {
print_header
@@ -231,7 +279,7 @@ main() {
echo
print_success "Espanso setup complete!"
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 "$@"

View File

@@ -6,7 +6,29 @@
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'
YELLOW='\033[1;33m'
RED='\033[0;31m'
@@ -24,22 +46,25 @@ print_error() {
echo -e "${RED}${NC} $1"
}
# ============================================================================
# Main
# ============================================================================
if [ ! -d "$DOTFILES_DIR" ]; then
print_error "Dotfiles directory not found: $DOTFILES_DIR"
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
fi
cd "$DOTFILES_DIR"
echo "Updating dotfiles from repository..."
git pull origin main
git pull origin "$DOTFILES_BRANCH"
if [ $? -eq 0 ]; then
print_success "Dotfiles updated successfully"
# Check if install script exists and run it
if [ -f "$DOTFILES_DIR/install.sh" ]; then
echo
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:
# Simple text replacement
- trigger: "..me"
replace: "Aaron D. Lee"
# --- 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 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
# ============================================================================
# Quick install: 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
# Quick install:
# 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
# ============================================================================
# Configuration
# Load Configuration
# ============================================================================
DOTFILES_REPO="https://github.com/adlee-was-taken/dotfiles.git"
DOTFILES_DIR="$HOME/.dotfiles"
BACKUP_DIR="$HOME/.dotfiles_backup_$(date +%Y%m%d_%H%M%S)"
load_config() {
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
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
# ============================================================================
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
NC='\033[0m'
# ============================================================================
# Helper Functions
@@ -28,7 +63,8 @@ NC='\033[0m' # No Color
print_header() {
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"
}
@@ -60,10 +96,28 @@ ask_yes_no() {
read -p "$prompt" response
response=${response:-$default}
[[ "$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
# ============================================================================
@@ -123,13 +177,16 @@ clone_or_update_dotfiles() {
print_warning "Dotfiles directory already exists"
if ask_yes_no "Update existing dotfiles?"; then
cd "$DOTFILES_DIR"
#git pull origin main
git pull origin "$DOTFILES_BRANCH"
print_success "Dotfiles updated"
fi
else
#git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
git clone "$DOTFILES_REPO_URL" "$DOTFILES_DIR"
print_success "Dotfiles cloned to $DOTFILES_DIR"
fi
# Reload config after clone (now we have dotfiles.conf)
load_config
}
backup_existing_configs() {
@@ -183,10 +240,10 @@ link_dotfiles() {
print_success "Linked: .zshrc"
fi
# Link adlee theme
if [ -f "$DOTFILES_DIR/zsh/themes/adlee.zsh-theme" ]; then
ln -sf "$DOTFILES_DIR/zsh/themes/adlee.zsh-theme" "$HOME/.oh-my-zsh/themes/adlee.zsh-theme"
print_success "Linked: adlee.zsh-theme"
# Link theme
if [ -f "$DOTFILES_DIR/zsh/themes/${ZSH_THEME_NAME}.zsh-theme" ]; then
ln -sf "$DOTFILES_DIR/zsh/themes/${ZSH_THEME_NAME}.zsh-theme" "$HOME/.oh-my-zsh/themes/${ZSH_THEME_NAME}.zsh-theme"
print_success "Linked: ${ZSH_THEME_NAME}.zsh-theme"
fi
# Link gitconfig
@@ -224,10 +281,21 @@ set_zsh_default() {
print_step "Setting zsh as default shell"
if [ "$SHELL" != "$(which zsh)" ]; then
if ask_yes_no "Set zsh as your default shell?"; then
chsh -s "$(which zsh)"
print_success "Default shell changed to zsh (restart required)"
fi
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
chsh -s "$(which zsh)"
print_success "Default shell changed to zsh (restart required)"
fi
;;
esac
else
print_success "zsh is already your default shell"
fi
@@ -243,16 +311,11 @@ install_espanso() {
case "$OS" in
ubuntu|debian)
# Install required dependencies
sudo apt-get install -y wget
# Download and install espanso
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
sudo apt install /tmp/espanso.deb
rm /tmp/espanso.deb
# Register espanso as a systemd service
espanso service register
print_success "espanso installed (X11 version)"
;;
@@ -265,26 +328,18 @@ install_espanso() {
espanso service register
print_success "espanso installed"
;;
arch)
# Check if paru is installed, if not try to install it
arch|cachyos)
if ! command -v paru &> /dev/null; then
print_warning "paru not found, attempting to install..."
# Install dependencies for building paru
sudo pacman -S --needed --noconfirm base-devel git
# Clone and build paru
cd /tmp
git clone https://aur.archlinux.org/paru.git
cd paru
makepkg -si --noconfirm
cd ~
rm -rf /tmp/paru
print_success "paru installed"
fi
# Install espanso using paru
paru -S --noconfirm espanso-bin
espanso service register
print_success "espanso installed"
@@ -306,26 +361,17 @@ link_espanso_config() {
print_step "Linking espanso configuration"
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 [ "$backup_needed" = false ]; then
mkdir -p "$BACKUP_DIR"
fi
mkdir -p "$BACKUP_DIR"
mv "$HOME/.config/espanso" "$BACKUP_DIR/espanso"
print_success "Backed up existing espanso config"
fi
# Remove old symlink if it exists
[ -L "$HOME/.config/espanso" ] && rm "$HOME/.config/espanso"
# Create .config directory if it doesn't exist
mkdir -p "$HOME/.config"
# Create symlink
ln -sf "$DOTFILES_DIR/espanso" "$HOME/.config/espanso"
print_success "Linked: espanso config"
# Restart espanso if it's running
if command -v espanso &> /dev/null; then
espanso restart 2>/dev/null || true
print_success "Restarted espanso service"
@@ -338,59 +384,43 @@ link_espanso_config() {
install_optional_tools() {
print_step "Optional tools"
# espanso - text expander
# espanso
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
fi
fi
# fzf - fuzzy finder
# fzf
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
~/.fzf/install --all
print_success "fzf installed"
fi
fi
# bat - better cat
# bat
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
ubuntu|debian)
sudo apt-get install -y bat
;;
fedora|rhel|centos)
sudo dnf install -y bat
;;
arch)
sudo pacman -S --noconfirm bat
;;
macos)
brew install bat
;;
ubuntu|debian) sudo apt-get install -y bat ;;
fedora|rhel|centos) sudo dnf install -y bat ;;
arch|cachyos) sudo pacman -S --noconfirm bat ;;
macos) brew install bat ;;
esac
print_success "bat installed"
fi
fi
# eza - better ls
# eza
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
ubuntu|debian)
sudo apt-get install -y eza
;;
fedora|rhel|centos)
sudo dnf install -y eza
;;
arch)
sudo pacman -S --noconfirm eza
;;
macos)
brew install eza
;;
ubuntu|debian) sudo apt-get install -y eza ;;
fedora|rhel|centos) sudo dnf install -y eza ;;
arch|cachyos) sudo pacman -S --noconfirm eza ;;
macos) brew install eza ;;
esac
print_success "eza installed"
fi
@@ -398,7 +428,7 @@ install_optional_tools() {
}
# ============================================================================
# Main Installation Flow
# Main
# ============================================================================
main() {
@@ -422,7 +452,7 @@ main() {
echo -e "${BLUE}Next steps:${NC}"
echo " 1. Restart your terminal or run: exec zsh"
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 -e "${BLUE}To update dotfiles in the future:${NC}"
echo " cd ~/.dotfiles && git pull && ./install.sh"
@@ -433,5 +463,4 @@ main() {
fi
}
# Run main function
main "$@"