From bcdc53a6e6f928f37505e317d9650aace4603d5c Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Sat, 13 Dec 2025 23:18:59 -0500 Subject: [PATCH] Initial commit: Add dotfiles and custom zsh theme --- .gitignore | 18 + bin/update-dotfiles.sh | 59 ++ espanso/config/default.yml | 52 ++ espanso/match/base.yml | 518 ++++++++++++++++++ espanso/match/packages/basic-emojis/README.md | 31 ++ .../match/packages/basic-emojis/_manifest.yml | 6 + .../packages/basic-emojis/_pkgsource.yml | 2 + .../match/packages/basic-emojis/package.yml | 27 + git/.gitconfig | 2 + install.sh | 437 +++++++++++++++ tmux/.tmux.conf | 7 + vim/.vimrc | 386 +++++++++++++ zsh/.zshrc | 109 ++++ zsh/themes/adlee.zsh-theme | 229 ++++++++ 14 files changed, 1883 insertions(+) create mode 100644 .gitignore create mode 100644 bin/update-dotfiles.sh create mode 100644 espanso/config/default.yml create mode 100644 espanso/match/base.yml create mode 100644 espanso/match/packages/basic-emojis/README.md create mode 100644 espanso/match/packages/basic-emojis/_manifest.yml create mode 100644 espanso/match/packages/basic-emojis/_pkgsource.yml create mode 100644 espanso/match/packages/basic-emojis/package.yml create mode 100644 git/.gitconfig create mode 100755 install.sh create mode 100644 tmux/.tmux.conf create mode 100644 vim/.vimrc create mode 100644 zsh/.zshrc create mode 100644 zsh/themes/adlee.zsh-theme diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2557ddb --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +cat > .gitignore << 'EOF' +# OS files +.DS_Store +Thumbs.db + +# Backup files +*.backup +*.bak +*~ + +# Local machine-specific configs +*.local + +# Sensitive information +.env +.env.* +secrets/ +EOF diff --git a/bin/update-dotfiles.sh b/bin/update-dotfiles.sh new file mode 100644 index 0000000..3cb3b93 --- /dev/null +++ b/bin/update-dotfiles.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# ============================================================================ +# Update Dotfiles Script +# ============================================================================ +# Updates dotfiles from the git repository and relinks files + +set -e + +DOTFILES_DIR="$HOME/.dotfiles" +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +RED='\033[0;31m' +NC='\033[0m' + +print_success() { + echo -e "${GREEN}✓${NC} $1" +} + +print_warning() { + echo -e "${YELLOW}⚠${NC} $1" +} + +print_error() { + echo -e "${RED}✗${NC} $1" +} + +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" + exit 1 +fi + +cd "$DOTFILES_DIR" + +echo "Updating dotfiles from repository..." +git pull origin main + +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 + response=${response:-y} + + if [[ "$response" =~ ^[Yy]$ ]]; then + "$DOTFILES_DIR/install.sh" + fi + fi + + echo + print_success "Update complete!" + echo "Reload your shell with: source ~/.zshrc" +else + print_error "Failed to update dotfiles" + exit 1 +fi diff --git a/espanso/config/default.yml b/espanso/config/default.yml new file mode 100644 index 0000000..e35b824 --- /dev/null +++ b/espanso/config/default.yml @@ -0,0 +1,52 @@ +# espanso configuration file + +# yaml-language-server: $schema=https://raw.githubusercontent.com/espanso/espanso/dev/schemas/config.schema.json + +# For a complete introduction, visit the official docs at: https://espanso.org/docs/ + +# You can use this file to define the global configuration options for espanso. +# These are the parameters that will be used by default on every application, +# but you can also override them on a per-application basis. + +# To make customization easier, this file contains some of the commonly used +# parameters. Feel free to uncomment and tune them to fit your needs! + +# --- Toggle key + +# Customize the key used to disable and enable espanso (when double tapped) +# Available options: CTRL, SHIFT, ALT, CMD, OFF +# You can also specify the key variant, such as LEFT_CTRL, RIGHT_SHIFT, etc... +# toggle_key: ALT +# You can also disable the toggle key completely with +# toggle_key: OFF + +# --- Injection Backend + +# Espanso supports multiple ways of injecting text into applications. Each of +# them has its quirks, therefore you may want to change it if you are having problems. +# By default, espanso uses the "Auto" backend which should work well in most cases, +# but you may want to try the "Clipboard" or "Inject" backend in case of issues. +# backend: Clipboard + +# --- Auto-restart + +# Enable/disable the config auto-reload after a file change is detected. +# auto_restart: false + +# --- Clipboard threshold + +# Because injecting long texts char-by-char is a slow operation, espanso automatically +# uses the clipboard if the text is longer than 'clipboard_threshold' characters. +# clipboard_threshold: 100 + +# --- Regex Buffer Size + +# The maximum number of characters to hold in memory for regex triggers. +# This value determines the maximum length of a regex trigger that can be +# matched by espanso and by default have 30 chars. +# It's advisable to keep this value reasonably low. +# You might want to increase this value if you have very long triggers, +# at the cost of higher memory usage. +# max_regex_buffer_size: 30 + +# For a list of all the available options, visit the official docs at: https://espanso.org/docs/ diff --git a/espanso/match/base.yml b/espanso/match/base.yml new file mode 100644 index 0000000..496f820 --- /dev/null +++ b/espanso/match/base.yml @@ -0,0 +1,518 @@ +# ============================================================================ +# Aaron D. Lee's Espanso matches +# 2025-12-13 +# ============================================================================ +# yaml-language-server: $schema=https://raw.githubusercontent.com/espanso/espanso/dev/schemas/match.schema.json + +matches: + # ========================================= + # Date and Time Stamps + # ========================================= + + # Print date stamp (YYYY-MM-DD) + - trigger: "..ds" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: date + params: + format: "%Y-%m-%d" + + - trigger: "..date" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: date + params: + format: "%Y-%m-%d" + + # Print short/filename date stamp (YYYYMMDD) + - trigger: "..sds" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: date + params: + format: "%Y%m%d" + + # Print UTC date/time stamp (ISO 8601) + - trigger: "..ts" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: shell + params: + cmd: 'date -u +"%Y-%m-%dT%H:%M:%S.%3NZ"' + + # Print current time w/ timezone + - trigger: "..ztime" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: shell + params: + cmd: 'date +"%H:%M:%S.%3N %Z"' + + # Print UTC time w/ timezone + - trigger: "..uztime" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: shell + params: + cmd: 'date -u +"%H:%M:%S.%3N %Z"' + + # Print current time + - trigger: "..time" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: shell + params: + cmd: 'date +"%H:%M:%S"' + + # Print UTC time + - trigger: "..utime" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: shell + params: + cmd: 'date -u +"%H:%M:%S"' + + # Print UTC date/time + - trigger: "..utc" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: shell + params: + cmd: 'date -u +"%Y-%m-%d %H:%M:%S.%3N %Z"' + + # Print date/time stamp + - trigger: "..dt" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: shell + params: + cmd: 'date +"%Y-%m-%d %H:%M:%S %Z"' + + # Print UTC date/time stamp + - trigger: "..udt" + replace: "{{date_stamp}}" + vars: + - name: date_stamp + type: shell + params: + cmd: 'date -u +"%Y-%m-%d %H:%M:%S %Z"' + + # Print month name + - trigger: "..month" + replace: "{{month}}" + vars: + - name: month + type: date + params: + format: "%B" + + # Print year + - trigger: "..year" + replace: "{{year}}" + vars: + - name: year + type: date + params: + format: "%Y" + + # Print week number + - trigger: "..week" + replace: "{{week}}" + vars: + - name: week + type: date + params: + format: "Week %U" + + # Print day of week + - trigger: "..day" + replace: "{{day}}" + vars: + - name: day + type: date + params: + format: "%A" + + # ========================================= + # Unix Timestamps + # ========================================= + + # Unix epoch timestamp + - trigger: "..epoch" + replace: "{{epoch}}" + vars: + - name: epoch + type: shell + params: + cmd: 'date +%s' + + # Unix epoch timestamp in milliseconds + - trigger: "..epochms" + replace: "{{epochms}}" + vars: + - name: epochms + type: shell + params: + cmd: 'date +%s%3N' + + # ========================================= + # Quick Text Replacements + # ========================================= + + - trigger: "..shrug" + replace: "¯\\_(ツ)_/¯" + + - trigger: "..flip" + replace: "(╯°□°)╯︵ ┻━┻" + + - trigger: "..unflip" + replace: "┬─┬ ノ( ゜-゜ノ)" + + - trigger: "..lenny" + replace: "( ͡° ͜ʖ ͡°)" + + - trigger: "..check" + replace: "✓" + + - trigger: "..cross" + replace: "✗" + + - trigger: "..arrow" + replace: "→" + + - trigger: "..larrow" + replace: "←" + + # ========================================= + # System Information + # ========================================= + + # Public IP address + - trigger: "..ip" + replace: "{{ip}}" + vars: + - name: ip + type: shell + params: + cmd: 'curl -s ifconfig.me' + + # Local IP address + - trigger: "..locip" + replace: "{{localip}}" + vars: + - name: localip + type: shell + params: + cmd: 'hostname -I | awk "{print $1}"' + + # ========================================= + # Git Shortcuts + # ========================================= + + - trigger: "..gstat" + replace: "git status" + + - trigger: "..gco" + replace: "git checkout " + + - trigger: "..gcm" + replace: "git commit -m \"\"" + + - trigger: "..glog" + replace: "git log --oneline --graph --decorate --all" + + - trigger: "..gpush" + replace: "git push origin " + + - trigger: "..gpull" + replace: "git pull origin " + + - trigger: "..gbranch" + replace: "git branch -a" + + - trigger: "..gdiff" + replace: "git diff" + + - trigger: "..gadd" + replace: "git add ." + + # Current git branch + - trigger: "..branch" + replace: "{{branch}}" + vars: + - name: branch + type: shell + params: + cmd: 'git branch --show-current 2>/dev/null || echo "not a git repo"' + + # ========================================= + # Docker Shortcuts + # ========================================= + + - trigger: "..dps" + replace: "docker ps" + + - trigger: "..dpsa" + replace: "docker ps -a" + + - trigger: "..dcup" + replace: "docker-compose up -d" + + - trigger: "..dcdown" + replace: "docker-compose down" + + - trigger: "..dlog" + replace: "docker logs -f " + + - trigger: "..dexec" + replace: "docker exec -it " + + - trigger: "..dim" + replace: "docker images" + + - trigger: "..dprune" + replace: "docker system prune -af" + + # ========================================= + # Code Templates + # ========================================= + + - trigger: "..bash" + replace: | + #!/usr/bin/env bash + + set -euo pipefail + + + - trigger: "..python" + replace: | + #!/usr/bin/env python3 + + def main(): + pass + + if __name__ == "__main__": + main() + + - trigger: "..she!" + replace: "#!/usr/bin/env bash" + + # ========================================= + # Markdown Helpers + # ========================================= + + - trigger: "..mdcode" + replace: | + ``` + {{cursor}} + ``` + + - trigger: "..mdbash" + replace: | + ```bash + {{cursor}} + ``` + + - trigger: "..mdpy" + replace: | + ```python + {{cursor}} + ``` + + - trigger: "..mdjs" + replace: | + ```javascript + {{cursor}} + ``` + + - trigger: "..mdtable" + replace: | + | Column 1 | Column 2 | Column 3 | + |----------|----------|----------| + | Cell 1 | Cell 2 | Cell 3 | + + - trigger: "..mdlink" + replace: "[{{text}}]({{url}})" + vars: + - name: text + type: form + params: + layout: "Link text: {{text}}" + - name: url + type: form + params: + layout: "URL: {{url}}" + + - trigger: "..mdimg" + replace: "![{{alt}}]({{url}})" + vars: + - name: alt + type: form + params: + layout: "Alt text: {{alt}}" + - name: url + type: form + params: + layout: "Image URL: {{url}}" + + # ========================================= + # Common Typo Corrections + # ========================================= + + - trigger: "teh" + replace: "the" + + - trigger: "recieve" + replace: "receive" + + - trigger: "seperator" + replace: "separator" + + - trigger: "definately" + replace: "definitely" + + - trigger: "occured" + replace: "occurred" + + - trigger: "lenght" + replace: "length" + + - trigger: "wierd" + replace: "weird" + + - trigger: "thier" + replace: "their" + + # ========================================= + # Lorem Ipsum + # ========================================= + + - trigger: "..lorem" + replace: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." + + - trigger: "..loremlong" + replace: | + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + + # ========================================= + # Quick Responses + # ========================================= + + - trigger: "..brb" + replace: "Be right back" + + - trigger: "..omw" + replace: "On my way" + + - trigger: "..tyvm" + replace: "Thank you very much" + + - trigger: "..lgtm" + replace: "Looks good to me" + + - trigger: "..wfm" + replace: "Works for me" + + - trigger: "..ack" + replace: "Acknowledged" + + - trigger: "..asap" + replace: "As soon as possible" + + # ========================================= + # File Paths & Navigation + # ========================================= + + - trigger: "..~" + replace: | + cd ~ + + - trigger: "..tmp" + replace: | + cd /tmp/ + + - trigger: "..logs" + replace: | + cd /var/log/ + + # ========================================= + # URLs & Links + # ========================================= + + - trigger: "..gh" + replace: "https://github.com" + + - trigger: "..gl" + replace: "https://gitlab.com" + + - trigger: "..gist" + replace: "https://gist.github.com" + + - trigger: "..so" + replace: "https://stackoverflow.com" + + - trigger: "..reddit" + replace: "https://reddit.com" + + # ========================================= + # Programming Comments + # ========================================= + + - trigger: "..todo" + replace: "// TODO: " + + - trigger: "..fixme" + replace: "// FIXME: " + + - trigger: "..note" + replace: "// NOTE: " + + - trigger: "..hack" + replace: "// HACK: " + + - trigger: "..debug" + replace: "// DEBUG: " + + # ========================================= + # Common Command Patterns + # ========================================= + + - trigger: "..ll" + replace: "ls -lah" + + - trigger: "..la" + replace: "ls -A" + + - trigger: "..grep" + replace: "grep -rni \"\" ." + + - trigger: "..find" + replace: "find . -name \"\"" + + - trigger: "..port" + replace: "lsof -i :" + + - trigger: "..kill" + replace: "kill -9 " + + - trigger: "..proc" + replace: "ps aux | grep " + + - trigger: "..disk" + replace: "df -h" + + - trigger: "..mem" + replace: "free -h" diff --git a/espanso/match/packages/basic-emojis/README.md b/espanso/match/packages/basic-emojis/README.md new file mode 100644 index 0000000..c200409 --- /dev/null +++ b/espanso/match/packages/basic-emojis/README.md @@ -0,0 +1,31 @@ +A simple package to bring basic emojis to espanso. +It works by replacing keywords like `:lol` with `😂`. More details below. + +### Installation + +Install the package with: + +``` +espanso install basic-emojis +``` + +### Usage + +This package replaces the following keywords with the associated emoji while you're +typing: + +Keyword | Emoji +--- | --- +`:lol` | 😂 +`:llol` | 😂😂😂😂 +`:sad` | ☹ +`:ssad` | ☹☹☹☹ +`:sml` | 😊 +`:strong` | 💪 +`:stlol` | 💪😂 +`:ba` | 😎 +`:ok` | 👍 +`:ook` | 👍👍👍👍 +`:happy` | 😄 +`:cry` | 😭 +`:wow` | 😮 \ No newline at end of file diff --git a/espanso/match/packages/basic-emojis/_manifest.yml b/espanso/match/packages/basic-emojis/_manifest.yml new file mode 100644 index 0000000..2cd2b8a --- /dev/null +++ b/espanso/match/packages/basic-emojis/_manifest.yml @@ -0,0 +1,6 @@ +author: Federico Terzi +description: A package to include some basic emojis in espanso. +name: basic-emojis +title: Basic Emojis +version: 0.1.0 +tags: ["emoji", "chat"] \ No newline at end of file diff --git a/espanso/match/packages/basic-emojis/_pkgsource.yml b/espanso/match/packages/basic-emojis/_pkgsource.yml new file mode 100644 index 0000000..0aa8f31 --- /dev/null +++ b/espanso/match/packages/basic-emojis/_pkgsource.yml @@ -0,0 +1,2 @@ +--- +hub diff --git a/espanso/match/packages/basic-emojis/package.yml b/espanso/match/packages/basic-emojis/package.yml new file mode 100644 index 0000000..fe4dfd3 --- /dev/null +++ b/espanso/match/packages/basic-emojis/package.yml @@ -0,0 +1,27 @@ +matches: + - trigger: ":lol" + replace: "😂" + - trigger: ":llol" + replace: "😂😂😂😂" + - trigger: ":sad" + replace: "☹" + - trigger: ":ssad" + replace: "☹☹☹☹" + - trigger: ":sml" + replace: "😊" + - trigger: ":strong" + replace: "💪" + - trigger: ":stlol" + replace: "💪😂" + - trigger: ":ba" + replace: "😎" + - trigger: ":ok" + replace: "👍" + - trigger: ":ook" + replace: "👍👍👍👍" + - trigger: ":happy" + replace: "😄" + - trigger: ":cry" + replace: "😭" + - trigger: ":wow" + replace: "😮" \ No newline at end of file diff --git a/git/.gitconfig b/git/.gitconfig new file mode 100644 index 0000000..200c0c9 --- /dev/null +++ b/git/.gitconfig @@ -0,0 +1,2 @@ +[init] + defaultBranch = master diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..74480fc --- /dev/null +++ b/install.sh @@ -0,0 +1,437 @@ +#!/usr/bin/env bash +# ============================================================================ +# ADLee's Dotfiles Installation Script +# ============================================================================ +# Quick install: curl -fsSL https://raw.githubusercontent.com/YOUR_USERNAME/dotfiles/main/install.sh | bash +# Or: git clone https://github.com/YOUR_USERNAME/dotfiles.git && cd dotfiles && ./install.sh + +set -e + +# ============================================================================ +# Configuration +# ============================================================================ + +DOTFILES_REPO="https://github.com/YOUR_USERNAME/dotfiles.git" +DOTFILES_DIR="$HOME/.dotfiles" +BACKUP_DIR="$HOME/.dotfiles_backup_$(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 + +# ============================================================================ +# Helper Functions +# ============================================================================ + +print_header() { + echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════╗${NC}" + echo -e "${BLUE}║${NC} ADLee's Dotfiles Installation ${BLUE}║${NC}" + echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}\n" +} + +print_step() { + echo -e "${GREEN}==>${NC} $1" +} + +print_success() { + echo -e "${GREEN}✓${NC} $1" +} + +print_warning() { + echo -e "${YELLOW}⚠${NC} $1" +} + +print_error() { + echo -e "${RED}✗${NC} $1" +} + +ask_yes_no() { + local prompt="$1" + local default="${2:-y}" + + if [[ "$default" == "y" ]]; then + prompt="$prompt [Y/n]: " + else + prompt="$prompt [y/N]: " + fi + + read -p "$prompt" response + response=${response:-$default} + + [[ "$response" =~ ^[Yy]$ ]] +} + +# ============================================================================ +# Installation Functions +# ============================================================================ + +detect_os() { + print_step "Detecting operating system" + + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + if [ -f /etc/os-release ]; then + . /etc/os-release + OS=$ID + OS_VERSION=$VERSION_ID + fi + print_success "Detected: Linux ($OS)" + elif [[ "$OSTYPE" == "darwin"* ]]; then + OS="macos" + print_success "Detected: macOS" + else + OS="unknown" + print_warning "Unknown OS: $OSTYPE" + fi +} + +install_dependencies() { + print_step "Installing dependencies" + + case "$OS" in + ubuntu|debian) + sudo apt-get update + sudo apt-get install -y git curl zsh + ;; + fedora|rhel|centos) + sudo dnf install -y git curl zsh + ;; + arch) + sudo pacman -Sy --noconfirm git curl zsh + ;; + macos) + if ! command -v brew &> /dev/null; then + print_warning "Homebrew not found. Installing..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + fi + brew install git curl zsh + ;; + *) + print_warning "Please install git, curl, and zsh manually" + ;; + esac + + print_success "Dependencies installed" +} + +clone_or_update_dotfiles() { + print_step "Setting up dotfiles repository" + + if [ -d "$DOTFILES_DIR" ]; then + print_warning "Dotfiles directory already exists" + if ask_yes_no "Update existing dotfiles?"; then + cd "$DOTFILES_DIR" + #git pull origin main + print_success "Dotfiles updated" + fi + else + #git clone "$DOTFILES_REPO" "$DOTFILES_DIR" + print_success "Dotfiles cloned to $DOTFILES_DIR" + fi +} + +backup_existing_configs() { + print_step "Backing up existing configurations" + + local files_to_backup=( + ".zshrc" + ".bashrc" + ".gitconfig" + ".vimrc" + ".tmux.conf" + ) + + local backup_needed=false + + for file in "${files_to_backup[@]}"; do + if [ -f "$HOME/$file" ] && [ ! -L "$HOME/$file" ]; then + if [ "$backup_needed" = false ]; then + mkdir -p "$BACKUP_DIR" + backup_needed=true + fi + cp "$HOME/$file" "$BACKUP_DIR/" + print_success "Backed up: $file" + fi + done + + if [ "$backup_needed" = true ]; then + print_success "Backups saved to: $BACKUP_DIR" + else + print_success "No backups needed" + fi +} + +install_oh_my_zsh() { + print_step "Installing oh-my-zsh" + + if [ -d "$HOME/.oh-my-zsh" ]; then + print_warning "oh-my-zsh already installed" + else + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended + print_success "oh-my-zsh installed" + fi +} + +link_dotfiles() { + print_step "Linking dotfiles" + + # Link zshrc + if [ -f "$DOTFILES_DIR/zsh/.zshrc" ]; then + ln -sf "$DOTFILES_DIR/zsh/.zshrc" "$HOME/.zshrc" + 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" + fi + + # Link gitconfig + if [ -f "$DOTFILES_DIR/git/.gitconfig" ]; then + ln -sf "$DOTFILES_DIR/git/.gitconfig" "$HOME/.gitconfig" + print_success "Linked: .gitconfig" + fi + + # Link vimrc + if [ -f "$DOTFILES_DIR/vim/.vimrc" ]; then + ln -sf "$DOTFILES_DIR/vim/.vimrc" "$HOME/.vimrc" + print_success "Linked: .vimrc" + fi + + # Link tmux.conf + if [ -f "$DOTFILES_DIR/tmux/.tmux.conf" ]; then + ln -sf "$DOTFILES_DIR/tmux/.tmux.conf" "$HOME/.tmux.conf" + print_success "Linked: .tmux.conf" + fi + + # Link bin scripts + if [ -d "$DOTFILES_DIR/bin" ]; then + mkdir -p "$HOME/.local/bin" + for script in "$DOTFILES_DIR/bin"/*; do + if [ -f "$script" ]; then + ln -sf "$script" "$HOME/.local/bin/$(basename "$script")" + chmod +x "$HOME/.local/bin/$(basename "$script")" + fi + done + print_success "Linked: bin scripts" + fi +} + +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 + else + print_success "zsh is already your default shell" + fi +} + +install_espanso() { + print_step "Installing espanso (text expander)" + + if command -v espanso &> /dev/null; then + print_warning "espanso already installed" + return 0 + fi + + 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)" + ;; + fedora|rhel|centos) + sudo dnf install -y wget + ESPANSO_VERSION="2.2.1" + wget "https://github.com/espanso/espanso/releases/download/v${ESPANSO_VERSION}/espanso-fedora-x11-amd64.rpm" -O /tmp/espanso.rpm + sudo dnf install /tmp/espanso.rpm + rm /tmp/espanso.rpm + espanso service register + print_success "espanso installed" + ;; + arch) + # Check if paru is installed, if not try to install it + 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" + ;; + macos) + brew tap espanso/espanso + brew install espanso + espanso service register + print_success "espanso installed" + ;; + *) + print_warning "Please install espanso manually from: https://espanso.org/install/" + return 1 + ;; + esac +} + +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 + 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" + fi + else + print_warning "No espanso config found in dotfiles" + fi +} + +install_optional_tools() { + print_step "Optional tools" + + # espanso - text expander + if ! command -v espanso &> /dev/null; then + if ask_yes_no "Install espanso (text expander)?"; then + install_espanso + fi + fi + + # fzf - fuzzy finder + if ! command -v fzf &> /dev/null; then + if ask_yes_no "Install 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 + if ! command -v bat &> /dev/null && ! command -v batcat &> /dev/null; then + if ask_yes_no "Install 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 + ;; + esac + print_success "bat installed" + fi + fi + + # eza - better ls + if ! command -v eza &> /dev/null; then + if ask_yes_no "Install 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 + ;; + esac + print_success "eza installed" + fi + fi +} + +# ============================================================================ +# Main Installation Flow +# ============================================================================ + +main() { + print_header + + detect_os + + if ask_yes_no "Install/update dotfiles?"; then + install_dependencies + clone_or_update_dotfiles + backup_existing_configs + install_oh_my_zsh + link_dotfiles + link_espanso_config + set_zsh_default + install_optional_tools + + echo + print_success "Installation complete!" + echo + 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 + echo -e "${BLUE}To update dotfiles in the future:${NC}" + echo " cd ~/.dotfiles && git pull && ./install.sh" + echo + else + print_warning "Installation cancelled" + exit 0 + fi +} + +# Run main function +main "$@" diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf new file mode 100644 index 0000000..c89df2b --- /dev/null +++ b/tmux/.tmux.conf @@ -0,0 +1,7 @@ +set-option -g default-shell /usr/bin/zsh +set -g pane-border-format "#{pane_index} #{pane_title}" +set -g pane-border-status bottom +bind-key U resize-pane -U 8 +bind-key D resize-pane -D 8 +bind-key L resize-pane -L 8 +bind-key R resize-pane -R 8 diff --git a/vim/.vimrc b/vim/.vimrc new file mode 100644 index 0000000..349d328 --- /dev/null +++ b/vim/.vimrc @@ -0,0 +1,386 @@ +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Maintainer: +" Amir Salihefendic - @amix3k +" +" Awesome_version: +" Get this config, nice color schemes and lots of plugins! +" +" Install the awesome version from: +" +" https://github.com/amix/vimrc +" +" Sections: +" -> General +" -> VIM user interface +" -> Colors and Fonts +" -> Files and backups +" -> Text, tab and indent related +" -> Visual mode related +" -> Moving around, tabs and buffers +" -> Status line +" -> Editing mappings +" -> vimgrep searching and cope displaying +" -> Spell checking +" -> Misc +" -> Helper functions +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => General +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Sets how many lines of history VIM has to remember +set history=500 + +" Enable filetype plugins +filetype plugin on +filetype indent on + +" Set to auto read when a file is changed from the outside +set autoread +au FocusGained,BufEnter * silent! checktime + +" With a map leader it's possible to do extra key combinations +" like w saves the current file +let mapleader = "," + +" Fast saving +nmap w :w! + +" :W sudo saves the file +" (useful for handling the permission-denied error) +command! W execute 'w !sudo tee % > /dev/null' edit! + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => VIM user interface +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Set 7 lines to the cursor - when moving vertically using j/k +set so=7 + +" Avoid garbled characters in Chinese language windows OS +let $LANG='en' +set langmenu=en +source $VIMRUNTIME/delmenu.vim +source $VIMRUNTIME/menu.vim + +" Turn on the Wild menu +set wildmenu + +" Ignore compiled files +set wildignore=*.o,*~,*.pyc +if has("win16") || has("win32") + set wildignore+=.git\*,.hg\*,.svn\* +else + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store +endif + +" Always show current position +set ruler + +" Height of the command bar +set cmdheight=1 + +" A buffer becomes hidden when it is abandoned +set hid + +" Configure backspace so it acts as it should act +set backspace=eol,start,indent +set whichwrap+=<,>,h,l + +" Ignore case when searching +set ignorecase + +" When searching try to be smart about cases +set smartcase + +" Highlight search results +set hlsearch + +" Makes search act like search in modern browsers +set incsearch + +" Don't redraw while executing macros (good performance config) +set lazyredraw + +" For regular expressions turn magic on +set magic + +" Show matching brackets when text indicator is over them +set showmatch + +" How many tenths of a second to blink when matching brackets +set mat=2 + +" No annoying sound on errors +set noerrorbells +set novisualbell +set t_vb= +set tm=500 + +" Properly disable sound on errors on MacVim +if has("gui_macvim") + autocmd GUIEnter * set vb t_vb= +endif + +" Add a bit extra margin to the left +set foldcolumn=1 + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Colors and Fonts +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Enable syntax highlighting +syntax enable + +" Set regular expression engine automatically +set regexpengine=0 + +" Enable 256 colors palette in Gnome Terminal +if $COLORTERM == 'gnome-terminal' + set t_Co=256 +endif + +try + colorscheme desert +catch +endtry + +set background=dark + +" Set extra options when running in GUI mode +if has("gui_running") + set guioptions-=T + set guioptions-=e + set t_Co=256 + set guitablabel=%M\ %t +endif + +" Set utf8 as standard encoding and en_US as the standard language +set encoding=utf8 + +" Use Unix as the standard file type +set ffs=unix,dos,mac + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Files, backups and undo +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Turn backup off, since most stuff is in SVN, git etc. anyway... +set nobackup +set nowb +set noswapfile + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Text, tab and indent related +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Use spaces instead of tabs +set expandtab + +" Be smart when using tabs ;) +set smarttab + +" 1 tab == 4 spaces +set shiftwidth=4 +set tabstop=4 + +" Linebreak on 500 characters +set lbr +set tw=500 + +set ai "Auto indent +set si "Smart indent +set wrap "Wrap lines + + +"""""""""""""""""""""""""""""" +" => Visual mode related +"""""""""""""""""""""""""""""" +" Visual mode pressing * or # searches for the current selection +" Super useful! From an idea by Michael Naumann +vnoremap * :call VisualSelection('', '')/=@/ +vnoremap # :call VisualSelection('', '')?=@/ + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Moving around, tabs, windows and buffers +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Map to / (search) and Ctrl- to ? (backwards search) +map / +map ? + +" Disable highlight when is pressed +map :noh + +" Smart way to move between windows +map j +map k +map h +map l + +" Close the current buffer +map bd :Bclose:tabclosegT + +" Close all the buffers +map ba :bufdo bd + +map l :bnext +map h :bprevious + +" Useful mappings for managing tabs +map tn :tabnew +map to :tabonly +map tc :tabclose +map tm :tabmove +map t :tabnext + +" Let 'tl' toggle between this and the last accessed tab +let g:lasttab = 1 +nmap tl :exe "tabn ".g:lasttab +au TabLeave * let g:lasttab = tabpagenr() + + +" Opens a new tab with the current buffer's path +" Super useful when editing files in the same directory +map te :tabedit =escape(expand("%:p:h"), " ")/ + +" Switch CWD to the directory of the open buffer +map cd :cd %:p:h:pwd + +" Specify the behavior when switching between buffers +try + set switchbuf=useopen,usetab,newtab + set stal=2 +catch +endtry + +" Return to last edit position when opening files (You want this!) +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + + +"""""""""""""""""""""""""""""" +" => Status line +"""""""""""""""""""""""""""""" +" Always show the status line +set laststatus=2 + +" Format the status line +set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Editing mappings +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Remap VIM 0 to first non-blank character +map 0 ^ + +" Move a line of text using ALT+[jk] or Command+[jk] on mac +nmap mz:m+`z +nmap mz:m-2`z +vmap :m'>+`mzgv`yo`z +vmap :m'<-2`>my` + nmap + vmap + vmap +endif + +" Delete trailing white space on save, useful for some filetypes ;) +fun! CleanExtraSpaces() + let save_cursor = getpos(".") + let old_query = getreg('/') + silent! %s/\s\+$//e + call setpos('.', save_cursor) + call setreg('/', old_query) +endfun + +if has("autocmd") + autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() +endif + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Spell checking +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Pressing ,ss will toggle and untoggle spell checking +map ss :setlocal spell! + +" Shortcuts using +map sn ]s +map sp [s +map sa zg +map s? z= + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Misc +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Remove the Windows ^M - when the encodings gets messed up +noremap m mmHmt:%s///ge'tzt'm + +" Quickly open a buffer for scribble +map q :e ~/buffer + +" Quickly open a markdown buffer for scribble +map x :e ~/buffer.md + +" Toggle paste mode on and off +map pp :setlocal paste! + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Helper functions +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Returns true if paste mode is enabled +function! HasPaste() + if &paste + return 'PASTE MODE ' + endif + return '' +endfunction + +" Don't close window, when deleting a buffer +command! Bclose call BufcloseCloseIt() +function! BufcloseCloseIt() + let l:currentBufNum = bufnr("%") + let l:alternateBufNum = bufnr("#") + + if buflisted(l:alternateBufNum) + buffer # + else + bnext + endif + + if bufnr("%") == l:currentBufNum + new + endif + + if buflisted(l:currentBufNum) + execute("bdelete! ".l:currentBufNum) + endif +endfunction + +function! CmdLine(str) + call feedkeys(":" . a:str) +endfunction + +function! VisualSelection(direction, extra_filter) range + let l:saved_reg = @" + execute "normal! vgvy" + + let l:pattern = escape(@", "\\/.*'$^~[]") + let l:pattern = substitute(l:pattern, "\n$", "", "") + + if a:direction == 'gv' + call CmdLine("Ack '" . l:pattern . "' " ) + elseif a:direction == 'replace' + call CmdLine("%s" . '/'. l:pattern . '/') + endif + + let @/ = l:pattern + let @" = l:saved_reg +endfunction diff --git a/zsh/.zshrc b/zsh/.zshrc new file mode 100644 index 0000000..7aaccc7 --- /dev/null +++ b/zsh/.zshrc @@ -0,0 +1,109 @@ +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH + +# Path to your Oh My Zsh installation. +export ZSH="$HOME/.oh-my-zsh" + +# Set name of the theme to load --- if set to "random", it will +# load a random theme each time Oh My Zsh is loaded, in which case, +# to know which specific one was loaded, run: echo $RANDOM_THEME +# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes +ZSH_THEME="adlee" + +zstyle ':omz:alpha:lib:git' async-prompt no + +# Set list of themes to pick from when loading at random +# Setting this variable when ZSH_THEME=random will cause zsh to load +# a theme from this variable instead of looking in $ZSH/themes/ +# If set to an empty array, this variable will have no effect. +# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) + +# Uncomment the following line to use case-sensitive completion. +# CASE_SENSITIVE="true" + +# Uncomment the following line to use hyphen-insensitive completion. +# Case-sensitive completion must be off. _ and - will be interchangeable. +# HYPHEN_INSENSITIVE="true" + +# Uncomment one of the following lines to change the auto-update behavior +# zstyle ':omz:update' mode disabled # disable automatic updates +# zstyle ':omz:update' mode auto # update automatically without asking +# zstyle ':omz:update' mode reminder # just remind me to update when it's time + +# Uncomment the following line to change how often to auto-update (in days). +# zstyle ':omz:update' frequency 13 + +# Uncomment the following line if pasting URLs and other text is messed up. +# DISABLE_MAGIC_FUNCTIONS="true" + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# You can also set it to another string to have that shown instead of the default red dots. +# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" +# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. +# You can set one of the optional three formats: +# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +# or set a custom format using the strftime function format specifications, +# see 'man strftime' for details. +# HIST_STAMPS="mm/dd/yyyy" + +# Would you like to use another custom folder than $ZSH/custom? +# ZSH_CUSTOM=/path/to/new-custom-folder + +# Which plugins would you like to load? +# Standard plugins can be found in $ZSH/plugins/ +# Custom plugins may be added to $ZSH_CUSTOM/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. +plugins=(git) + +source $ZSH/oh-my-zsh.sh + +# User configuration + +# export MANPATH="/usr/local/man:$MANPATH" + +# You may need to manually set your language environment +# export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='nvim' +# fi + +# Compilation flags +# export ARCHFLAGS="-arch $(uname -m)" + +# Set personal aliases, overriding those provided by Oh My Zsh libs, +# plugins, and themes. Aliases can be placed here, though Oh My Zsh +# users are encouraged to define aliases within a top-level file in +# the $ZSH_CUSTOM folder, with .zsh extension. Examples: +# - $ZSH_CUSTOM/aliases.zsh +# - $ZSH_CUSTOM/macos.zsh +# For a full list of active aliases, run `alias`. +# +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" +alias vispresso="vim ~/.config/espanso/match/base.yml" + + diff --git a/zsh/themes/adlee.zsh-theme b/zsh/themes/adlee.zsh-theme new file mode 100644 index 0000000..aebe9d0 --- /dev/null +++ b/zsh/themes/adlee.zsh-theme @@ -0,0 +1,229 @@ +#!/usr/bin/env zsh +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# % ~/.oh-my-zsh/themes/adlee.zsh-theme +# === ADLee's zsh (oh-my-zsh) Theme === +# ===================================== + +# ============================================================================ +# CONFIGURATION & CONSTANTS +# ============================================================================ + +# Prevent multiple initialization on reload +if [[ -z "$_ADLEE_THEME_LOADED" ]]; then + export _ADLEE_THEME_LOADED=1 + + export KEYTIMEOUT=1 + + # Color definitions + typeset -gr COLOR_GREY='%{$FG[239]%}' + typeset -gr COLOR_YELLOW='%{$FG[179]%}' + typeset -gr COLOR_BLUE='%{$FG[069]%}' + typeset -gr COLOR_GREEN='%{$FG[118]%}' + typeset -gr COLOR_RED='%{$FG[196]%}' + typeset -gr COLOR_ORANGE='%{$FG[220]%}' + typeset -gr COLOR_LIGHT_ORANGE='%{$FG[228]%}' + typeset -gr COLOR_LIGHT_GREEN='%{$FG[002]%}' + typeset -gr COLOR_BRIGHT_GREEN='%{$FG[010]%}' + typeset -gr COLOR_RESET='%{$reset_color%}' + typeset -gr COLOR_BOLD='%{$FX[bold]%}' + + # Prompt characters + typeset -gr PROMPT_CHAR_USER="${COLOR_GREY}└${COLOR_BOLD}${COLOR_BLUE}%#${COLOR_RESET} " + typeset -gr PROMPT_CHAR_ROOT="${COLOR_GREY}└${COLOR_BOLD}${COLOR_RED}%#${COLOR_RESET} " + + # Path truncation threshold + typeset -gr PATH_TRUNCATE_LENGTH=32 + + # Timer threshold (seconds) + typeset -gr TIMER_THRESHOLD=10 +fi + +# ============================================================================ +# GIT PROMPT CONFIGURATION +# ============================================================================ + +ZSH_THEME_GIT_PROMPT_PREFIX="]─[%{$fg_bold[green]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color$FG[239]%}" +ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*%{$fg[green]%}" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +# ============================================================================ +# HELPER FUNCTIONS +# ============================================================================ + +# Get shortened path (last two directories if path is too long) +_adlee_get_short_path() { + local full_path="$(pwd | sed -e 's/\/Users\/alee/~/g')" + local path_len=$(echo -n "$full_path" | wc -m | tr -d ' ') + + if [ "$path_len" -gt "$PATH_TRUNCATE_LENGTH" ]; then + local short_path=$(pwd | awk -F '/' '{print $(NF - 1)"/"$NF}') + echo "${COLOR_YELLOW}⋯${COLOR_RESET}${COLOR_GREY}${COLOR_YELLOW}/${short_path}${COLOR_RESET}${COLOR_GREY}" + else + echo "${COLOR_YELLOW}%~${COLOR_RESET}${COLOR_GREY}" + fi +} + +# Get appropriate prompt character based on user +_adlee_get_prompt_char() { + if [[ $UID == 0 || $EUID == 0 ]]; then + echo "$PROMPT_CHAR_ROOT" + else + echo "$PROMPT_CHAR_USER" + fi +} + +# Format user@host section +_adlee_format_user_host() { + echo "${COLOR_GREEN}%n@%m${COLOR_RESET}${COLOR_GREY}" +} + +# Format current directory with git info +_adlee_format_directory() { + local short_path="$(_adlee_get_short_path)" + local git_info='$(git_prompt_info)'"${COLOR_GREY}" + echo "${short_path}${git_info}" +} + +# ============================================================================ +# COMMAND TIMER FUNCTIONS +# ============================================================================ + +# Format elapsed time based on duration +_adlee_format_elapsed_time() { + local elapsed=$1 + local timestamp="%D{%Y-%m-%d %I:%M:%S}" + + if [[ $elapsed -ge 3600 ]]; then + # Hours + local hours=$((elapsed / 3600)) + local remainder=$((elapsed % 3600)) + local minutes=$((remainder / 60)) + local seconds=$((remainder % 60)) + print -P "${COLOR_RED}•─[ completed in: %b%B${COLOR_RED}${hours}h${minutes}m${seconds}s%b${COLOR_RED} at: %b%B${COLOR_RED}${timestamp}%b${COLOR_RED} ]─•%b" + elif [[ $elapsed -ge 60 ]]; then + # Minutes + local minutes=$((elapsed / 60)) + local seconds=$((elapsed % 60)) + print -P "${COLOR_ORANGE}•─[ completed in: %b%B${COLOR_LIGHT_ORANGE}${minutes}m${seconds}s%b${COLOR_ORANGE} at: %b%B${COLOR_LIGHT_ORANGE}${timestamp}%b${COLOR_ORANGE} ]─•%b" + else + # Seconds only + print -P "${COLOR_LIGHT_GREEN}•─[ completed in: %b%B${COLOR_BRIGHT_GREEN}${elapsed}s%b${COLOR_BRIGHT_GREEN} at: %b%B${COLOR_LIGHT_GREEN}${timestamp}%b${COLOR_LIGHT_GREEN} ]─•%b" + fi +} + +# ============================================================================ +# PROMPT BUILDING +# ============================================================================ + +_adlee_build_prompt() { + local user_host="$(_adlee_format_user_host)" + local directory="$(_adlee_format_directory)" + + # Build top line: ┌[user@host]─[directory] + local top_line="${COLOR_GREY}┌[${user_host}]─[${directory}]" + + print -P "${top_line}" + + # Set bottom line prompt character + PROMPT="$(_adlee_get_prompt_char)" +} + +# ============================================================================ +# ZSH HOOKS +# ============================================================================ + +adlee_preexec() { + cmd_start_time=$SECONDS + echo -ne "\e[0m" +} + +adlee_precmd() { + # Handle command timer + if [[ -n $cmd_start_time ]]; then + local elapsed=$((SECONDS - cmd_start_time)) + if [[ $elapsed -gt $TIMER_THRESHOLD ]]; then + _adlee_format_elapsed_time $elapsed + fi + unset cmd_start_time + fi + + # Configure ZLE highlighting + zle_highlight=( default:fg=white ) + + # Rebuild prompt + _adlee_build_prompt +} + +TRAPALRM() { + _adlee_build_prompt + if [[ "$WIDGET" != "expand-or-complete" ]]; then + zle reset-prompt + fi +} + +# ============================================================================ +# UTILITY FUNCTIONS +# ============================================================================ + +# Search command history +histsearch() { + fc -lim "$@" 1 +} + +# ============================================================================ +# INITIALIZATION +# ============================================================================ + +# Load required functions +autoload -Uz add-zsh-hook + +# Register hooks +add-zsh-hook preexec adlee_preexec +add-zsh-hook precmd adlee_precmd + +# Configure ZLE +zle -N zle-line-init +zle -N zle-keymap-select + +# Define zshrc reload function and widget +reload-zshrc() { + echo -n "Re-sourcing \`~/.zshrc.\` ... " + source ~/.zshrc + echo "Completed." + _adlee_build_prompt + zle reset-prompt +} +zle -N reload-zshrc # Register as a widget +bindkey "^X@s^[^R" reload-zshrc # Bind to Ctrl+Super+Alt+R + + # Function. +grab-fastfetch() { + echo "fastfetch" + fastfetch + _adlee_build_prompt + zle reset-prompt +} +zle -N grab-fastfetch # Register as a widget +bindkey "^X@s^[^F" grab-fastfetch # Bind to Ctrl+Super+Alt+F + + +# ============================================================================ +# DEPLOYMENT NOTES +# ============================================================================ +# For system-wide deployment, use one of these approaches: +# +# OPTION 1: Symlink (Recommended) +# Master location: /usr/local/share/zsh/themes/adlee.zsh-theme +# User symlinks: +# ln -sf /usr/local/share/zsh/themes/adlee.zsh-theme ~/.oh-my-zsh/themes/adlee.zsh-theme +# sudo ln -sf /usr/local/share/zsh/themes/adlee.zsh-theme /root/.oh-my-zsh/themes/adlee.zsh-theme +# +# OPTION 2: Source from shared location +# In each user's ~/.zshrc (before oh-my-zsh initialization): +# source /usr/local/share/zsh/themes/adlee.zsh-theme +# +# OPTION 3: Custom oh-my-zsh location +# Set in ~/.zshrc: +# export ZSH_CUSTOM="/usr/local/share/oh-my-zsh-custom" +# Then place theme in: /usr/local/share/oh-my-zsh-custom/themes/adlee.zsh-theme