🚀 Complete machine migration setup with encrypted backups
- Added comprehensive configuration files for seamless migration - SSH, GPG, Karabiner, iTerm2, Neofetch, SwiftBar configs - Pass license management system with templates and documentation - Enhanced shell functions with MAS updates and moon phase tracking - Comprehensive encrypted backup system (GPG AES256) - Included encrypted backups of all sensitive data - BBEdit as default editor with proper configuration - Fixed shell compatibility issues - Merged existing .zsh configs with improvements Security: - All sensitive data is GPG encrypted (.gpg files) - Private keys excluded from version control - Only configs and encrypted backups are tracked Following prime directive: durable, thoughtful solutions 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
a0e34f78ae
commit
389febb161
@@ -0,0 +1,19 @@
|
||||
# Core enhancements
|
||||
romkatv/powerlevel10k
|
||||
zsh-users/zsh-completions
|
||||
zsh-users/zsh-autosuggestions
|
||||
zsh-users/zsh-syntax-highlighting
|
||||
|
||||
# Useful navigation & productivity
|
||||
rupa/z # Jump around directories
|
||||
djui/alias-tips # Show hints when alias could be used
|
||||
chisui/zsh-nix-shell # If using Nix at some point
|
||||
|
||||
# Git integration
|
||||
olivierverdier/zsh-git-prompt # Lightweight git aliases/completions
|
||||
|
||||
# FZF integration (optional, only if you use fzf)
|
||||
unixorn/fzf-zsh-plugin
|
||||
|
||||
# Completions (optional, only if you reinstall these tools)
|
||||
# mullvad/mullvad-zsh-completions
|
||||
@@ -0,0 +1,94 @@
|
||||
# ░█▀█░█░░░▀█▀░█▀█░█▀▀░█▀▀░█▀▀
|
||||
# ░█▀█░█░░░░█░░█▀█░▀▀█░█▀▀░▀▀█
|
||||
# ░▀░▀░▀▀▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀
|
||||
|
||||
|
||||
alias gs='git status'
|
||||
alias kaicd='cd ~/Vault/08. Notes/Children/Kai'
|
||||
|
||||
## II. File checksum verification ##
|
||||
alias verify1='openssl sha1'
|
||||
alias verify256='openssl dgst -sha256'
|
||||
|
||||
## III. Easier navigation: .., ..., ...., and .....
|
||||
alias ..="cd .."
|
||||
alias ...="cd ../.."
|
||||
alias ....="cd ../../.."
|
||||
alias .....="cd ../../../.."
|
||||
|
||||
## IV. Shortcuts
|
||||
alias dl="cd ~/Downloads"
|
||||
alias dt="cd ~/Desktop"
|
||||
alias docs="cd ~/Documents"
|
||||
|
||||
# use eza
|
||||
alias ls='eza --color=auto --group-directories-first --icons'
|
||||
alias ll='eza -lgh --git'
|
||||
alias la='eza -la --git'
|
||||
alias lt='eza --tree'
|
||||
|
||||
# use coreutils ls
|
||||
# alias ls='gls --color=auto'
|
||||
# List all files in long format
|
||||
# alias l="gls -lF --color=auto"
|
||||
# List all files in long format, excluding . and ..
|
||||
# alias la="gls -lAF --color=auto"
|
||||
# List only directories
|
||||
# alias lsd="gls -lF | grep --color=never '^d'"
|
||||
# alias ll='gls -lah --color=aut'
|
||||
|
||||
# view man pages with bat (replaced by enhanced man function in functions.zsh)
|
||||
# alias batman='man -P "bat -l man -p"'
|
||||
|
||||
# Get macOS Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
|
||||
alias update="read -q 'REPLY?Run full system update? (y/n) ' && echo && sysupdate || echo 'Aborted.'"
|
||||
# Maintenance scripts
|
||||
alias mrclean='sudo periodic daily weekly monthly'
|
||||
# Download using cURL
|
||||
alias dl="curl -O"
|
||||
# yt-dlp at best quility and in .mp4 format
|
||||
alias yt="yt-dlp -S res,ext:mp4:m4a --recode mp4"
|
||||
# Internet speed test with Cloudfare CLI
|
||||
alias speed="npx speed-cloudflare-cli"
|
||||
# IP addresses
|
||||
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
|
||||
alias localip="ipconfig getifaddr en0"
|
||||
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
|
||||
# Clean up LaunchServices to remove duplicates in the “Open With” menu
|
||||
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
|
||||
# Recursively delete `.DS_Store` files
|
||||
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
|
||||
# Empty the Trash on all mounted volumes and the main HDD.
|
||||
# Also, clear Apple’s System Logs to improve shell startup speed.
|
||||
# Finally, clear download history from quarantine. https://mths.be/bum
|
||||
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
|
||||
# Show/hide hidden files in Finder
|
||||
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
||||
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
|
||||
# Disable Spotlight
|
||||
alias spotoff="sudo mdutil -a -i off"
|
||||
# Enable Spotlight
|
||||
alias spoton="sudo mdutil -a -i on"
|
||||
# Lock the screen (when going AFK)
|
||||
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
|
||||
# Access quicklook from terminal
|
||||
alias ql="qlmanage -p "
|
||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||
|
||||
## Animal Rationis Capax
|
||||
# work session
|
||||
alias arc="cd /Users/davidglidden/Documents/GitHub/davidglidden.github.io && claude 'Context initialization:
|
||||
Please read these files in order:
|
||||
1. CLAUDE.md - Project instructions and workflow triggers
|
||||
2. docs/internal/collaboration-protocol.md - Our working relationship
|
||||
3. docs/internal/project-memory.md - Complete development history
|
||||
4. docs/chamber/workflow/MODE-1-UNIFIED.md - Current Chamber operations
|
||||
5. docs/style-guide.md - Editorial guidelines and notation system
|
||||
|
||||
After reading, confirm you understand the current state and are ready for today'\''s work.'"
|
||||
|
||||
# glimpse processing
|
||||
alias glimpse='cd ~/animal-davidglidden-eu/tools/glimpse-processing && source venv/bin/activate && python glimpse_tool.py'
|
||||
|
||||
## Tetris
|
||||
alias tetris='/opt/homebrew/opt/vitetris/bin/tetris'
|
||||
+58
-157
@@ -2,155 +2,82 @@
|
||||
# ░█▀█░█░░░░█░░█▀█░▀▀█░█▀▀░▀▀█
|
||||
# ░▀░▀░▀▀▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀
|
||||
|
||||
# Enhanced aliases with intelligent fallbacks and context awareness
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# I. NAVIGATION & LISTING
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
alias gs='git status'
|
||||
alias kaicd='cd ~/Vault/08. Notes/Children/Kai'
|
||||
|
||||
# Enhanced navigation with consistent patterns
|
||||
## II. File checksum verification ##
|
||||
alias verify1='openssl sha1'
|
||||
alias verify256='openssl dgst -sha256'
|
||||
|
||||
## III. Easier navigation: .., ..., ...., and .....
|
||||
alias ..="cd .."
|
||||
alias ...="cd ../.."
|
||||
alias ....="cd ../../.."
|
||||
alias .....="cd ../../../.."
|
||||
alias -- -="cd -" # Go back to previous directory
|
||||
|
||||
# Context-aware directory shortcuts
|
||||
## IV. Shortcuts
|
||||
alias dl="cd ~/Downloads"
|
||||
alias dt="cd ~/Desktop"
|
||||
alias docs="cd ~/Documents"
|
||||
alias vault="cd '$VAULT_PATH'"
|
||||
alias chamber="cd '$CHAMBER_PATH'"
|
||||
alias work="cd '$WORK_PATH'"
|
||||
alias dotfiles="cd '$DOTFILES_PATH'"
|
||||
|
||||
# Vault-specific navigation
|
||||
alias daily="cd '$VAULT_PATH/01. Daily'"
|
||||
alias notes="cd '$VAULT_PATH/08. Notes'"
|
||||
alias projects="cd '$VAULT_PATH/06. Projects'"
|
||||
alias templates="cd '$VAULT_PATH/98. Templates'"
|
||||
# use eza
|
||||
alias ls='eza --color=auto --group-directories-first --icons'
|
||||
alias ll='eza -lgh --git'
|
||||
alias la='eza -la --git'
|
||||
alias lt='eza --tree'
|
||||
|
||||
# Enhanced listing with eza (fallback to ls)
|
||||
if command -v eza >/dev/null 2>&1; then
|
||||
alias ls='eza --color=auto --group-directories-first --icons'
|
||||
alias ll='eza -lgh --git --time-style=relative'
|
||||
alias la='eza -la --git --time-style=relative'
|
||||
alias lt='eza --tree --level=2 --icons --git'
|
||||
alias ltree='eza --tree --icons --git'
|
||||
alias lx='eza -lgh --sort=extension --git'
|
||||
alias lk='eza -lgh --sort=size --git'
|
||||
alias lt='eza -lgh --sort=modified --git'
|
||||
else
|
||||
# Fallback to standard ls with colors
|
||||
alias ls='ls --color=auto'
|
||||
alias ll='ls -lh'
|
||||
alias la='ls -lah'
|
||||
alias lt='ls -lt'
|
||||
fi
|
||||
# use coreutils ls
|
||||
# alias ls='gls --color=auto'
|
||||
# List all files in long format
|
||||
# alias l="gls -lF --color=auto"
|
||||
# List all files in long format, excluding . and ..
|
||||
# alias la="gls -lAF --color=auto"
|
||||
# List only directories
|
||||
# alias lsd="gls -lF | grep --color=never '^d'"
|
||||
# alias ll='gls -lah --color=aut'
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# II. GIT & VERSION CONTROL
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# view man pages with bat (replaced by enhanced man function in functions.zsh)
|
||||
# alias batman='man -P "bat -l man -p"'
|
||||
|
||||
alias gs='git status'
|
||||
alias ga='git add'
|
||||
alias gc='git commit'
|
||||
alias gp='git push'
|
||||
alias gl='git pull'
|
||||
alias gd='git diff'
|
||||
alias gb='git branch'
|
||||
alias gco='git checkout'
|
||||
alias glog='git log --oneline --graph --decorate'
|
||||
|
||||
# Enhanced git aliases
|
||||
alias gss='git status --short'
|
||||
alias gaa='git add --all'
|
||||
alias gcm='git commit -m'
|
||||
alias gcam='git commit -am'
|
||||
alias gundo='git reset --soft HEAD~1'
|
||||
alias gclean='git clean -fd'
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# III. SEARCH & TEXT PROCESSING
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Enhanced search with ripgrep (fallback to grep)
|
||||
if command -v rg >/dev/null 2>&1; then
|
||||
alias grep='rg --smart-case --follow --color=always'
|
||||
alias greph='rg --hidden --follow --color=always'
|
||||
alias grepi='rg --ignore-case --follow --color=always'
|
||||
else
|
||||
alias grep='grep --color=auto'
|
||||
alias grepi='grep -i --color=auto'
|
||||
fi
|
||||
|
||||
# Enhanced cat with bat (fallback to cat)
|
||||
if command -v bat >/dev/null 2>&1; then
|
||||
alias cat='bat --style=auto'
|
||||
alias ccat='bat --style=plain' # Plain cat equivalent
|
||||
else
|
||||
alias bat='cat'
|
||||
fi
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# IV. MEDIA & DOWNLOADS
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Download utilities
|
||||
# Get macOS Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
|
||||
alias update="read -q 'REPLY?Run full system update? (y/n) ' && echo && sysupdate || echo 'Aborted.'"
|
||||
# Maintenance scripts
|
||||
alias mrclean='sudo periodic daily weekly monthly'
|
||||
# Download using cURL
|
||||
alias dl="curl -O"
|
||||
# yt-dlp at best quility and in .mp4 format
|
||||
alias yt="yt-dlp -S res,ext:mp4:m4a --recode mp4"
|
||||
alias yta="yt-dlp -x --audio-format mp3"
|
||||
|
||||
# Quick media info
|
||||
alias mediainfo='ffprobe -v quiet -print_format json -show_format -show_streams'
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# V. SYSTEM MONITORING & NETWORK
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Network information
|
||||
# Internet speed test with Cloudfare CLI
|
||||
alias speed="npx speed-cloudflare-cli"
|
||||
# IP addresses
|
||||
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
|
||||
alias localip="ipconfig getifaddr en0"
|
||||
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
|
||||
|
||||
# Speed and connectivity
|
||||
alias speed="npx speed-cloudflare-cli"
|
||||
alias ping="ping -c 5"
|
||||
alias pingg="ping google.com"
|
||||
|
||||
# System monitoring
|
||||
alias cpu="top -F -R -o cpu"
|
||||
alias mem="top -F -R -o rsize"
|
||||
alias ports="lsof -i -P | grep LISTEN"
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# VI. MACOS SPECIFIC
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Finder and system
|
||||
# Clean up LaunchServices to remove duplicates in the “Open With” menu
|
||||
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
|
||||
# Recursively delete `.DS_Store` files
|
||||
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
|
||||
# Empty the Trash on all mounted volumes and the main HDD.
|
||||
# Also, clear Apple’s System Logs to improve shell startup speed.
|
||||
# Finally, clear download history from quarantine. https://mths.be/bum
|
||||
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
|
||||
# Show/hide hidden files in Finder
|
||||
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
||||
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
|
||||
alias ql="qlmanage -p" # Quick Look from terminal
|
||||
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
|
||||
|
||||
# Spotlight control
|
||||
# Disable Spotlight
|
||||
alias spotoff="sudo mdutil -a -i off"
|
||||
# Enable Spotlight
|
||||
alias spoton="sudo mdutil -a -i on"
|
||||
# Lock the screen (when going AFK)
|
||||
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
|
||||
# Access quicklook from terminal
|
||||
alias ql="qlmanage -p "
|
||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# VII. CHECKSUMS & SECURITY
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
alias verify1='openssl sha1'
|
||||
alias verify256='openssl dgst -sha256'
|
||||
alias verify512='openssl dgst -sha512'
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# VIII. WORKFLOW SPECIFIC
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Work context (Animal Rationis Capax)
|
||||
alias arc="cd '$WORK_PATH' && claude 'Context initialization:
|
||||
## Animal Rationis Capax
|
||||
# work session
|
||||
alias arc="cd /Users/davidglidden/Documents/GitHub/davidglidden.github.io && claude 'Context initialization:
|
||||
Please read these files in order:
|
||||
1. CLAUDE.md - Project instructions and workflow triggers
|
||||
2. docs/internal/collaboration-protocol.md - Our working relationship
|
||||
@@ -160,38 +87,12 @@ Please read these files in order:
|
||||
|
||||
After reading, confirm you understand the current state and are ready for today'\''s work.'"
|
||||
|
||||
# Glimpse processing
|
||||
alias glimpse="cd '$CHAMBER_PATH/tools/glimpse-processing' && source venv/bin/activate && python glimpse_tool.py"
|
||||
# glimpse processing
|
||||
alias glimpse='cd ~/animal-davidglidden-eu/tools/glimpse-processing && source venv/bin/activate && python glimpse_tool.py'
|
||||
|
||||
# Entertainment
|
||||
## Tetris
|
||||
alias tetris='/opt/homebrew/opt/vitetris/bin/tetris'
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# IX. MAINTENANCE & UPDATES
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# System maintenance (interactive confirmation)
|
||||
alias update="read -q 'REPLY?Run full system update? (y/n) ' && echo && sysupdate || echo 'Aborted.'"
|
||||
alias mrclean='sudo periodic daily weekly monthly'
|
||||
|
||||
# Comprehensive cleanup
|
||||
alias cleanup='deep_clean' # References function in functions.zsh
|
||||
|
||||
# Quick dotfiles management
|
||||
alias dotfiles-backup='$DOTFILES_PATH/bin/backup-dotfiles'
|
||||
alias dotfiles-status='$DOTFILES_PATH/bin/check-app-configs'
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# X. DOTFILES SYSTEM TOOLS
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Health monitoring and maintenance
|
||||
alias health='~/dotfiles/scripts/system-health.sh'
|
||||
alias drift='~/dotfiles/scripts/detect-drift.sh'
|
||||
alias lockfile='~/dotfiles/scripts/generate-lockfile.sh'
|
||||
alias safe-update='~/dotfiles/scripts/safe-update.sh'
|
||||
|
||||
# Quick health checks
|
||||
alias health-monitor='~/dotfiles/scripts/system-health.sh monitor'
|
||||
alias health-json='~/dotfiles/scripts/system-health.sh json'
|
||||
alias drift-quiet='~/dotfiles/scripts/detect-drift.sh --quiet'
|
||||
## Pass license management shortcuts
|
||||
alias licenses='pass ls licenses/'
|
||||
alias license='pass show licenses/'
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
# Core environment variables with graceful fallbacks
|
||||
|
||||
# 🖋 Preferred editors
|
||||
export EDITOR="${EDITOR:-bbedit}"
|
||||
export VISUAL="${VISUAL:-bbedit}"
|
||||
export EDITOR="bbedit -w"
|
||||
export VISUAL="bbedit -w"
|
||||
|
||||
# 🌍 Locale settings
|
||||
export LANG="${LANG:-en_US.UTF-8}"
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
# ░█▀▀░█░█░█▀█░█▀▀░▀█▀░▀█▀░█▀█░█▀█░█▀▀
|
||||
# ░█▀▀░█░█░█░█░█░░░░█░░░█░░█░█░█░█░▀▀█
|
||||
# ░▀░░░▀▀▀░▀░▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀░▀░▀▀▀
|
||||
|
||||
## I. PDF Compression #######################
|
||||
pdfcompress ()
|
||||
{
|
||||
gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/screen -dEmbedAllFonts=true -dSubsetFonts=true -dColorImageDownsampleType=/Bicubic -dColorImageResolution=144 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=144 -dMonoImageDownsampleType=/Bicubic -dMonoImageResolution=144 -sOutputFile=$1.compressed.pdf $1;
|
||||
}
|
||||
|
||||
## II. Weather #######################
|
||||
|
||||
wttr() {
|
||||
# Usage: wttr [location]
|
||||
# Examples: wttr -> your IP-based location
|
||||
# wttr 75012 -> Paris 12e
|
||||
# wttr 23190 -> Crozant
|
||||
local location=${1:-}
|
||||
curl -s "wttr.in/${location}?n"
|
||||
}
|
||||
|
||||
## III. Updates (system, brew, etc) #######################
|
||||
## Description: Performs system updates, Homebrew cleanup, fzf refresh, moon phase logging, and dotfile sync ###########################
|
||||
|
||||
function sysupdate() {
|
||||
local start_time=$(date +%s)
|
||||
echo "🔧 Starting full system update at $(date)"
|
||||
|
||||
# Ensure sudo credentials are fresh
|
||||
if ! sudo -vn 2>/dev/null; then
|
||||
echo "🔒 sudo authentication required..."
|
||||
sudo -v
|
||||
fi
|
||||
|
||||
echo "🍎 Updating macOS Software..."
|
||||
sudo softwareupdate -i -a
|
||||
|
||||
echo "🍺 Updating Homebrew packages..."
|
||||
brew update
|
||||
brew upgrade
|
||||
brew cleanup
|
||||
brew autoremove
|
||||
|
||||
# Mac App Store updates
|
||||
echo "🍎 Updating Mac App Store apps..."
|
||||
if command -v mas >/dev/null; then
|
||||
local mas_outdated=$(mas outdated)
|
||||
if [[ -n "$mas_outdated" ]]; then
|
||||
echo "📱 Updating MAS apps:"
|
||||
echo "$mas_outdated" | while read -r line; do
|
||||
echo " $line"
|
||||
done
|
||||
mas upgrade || echo "⚠️ Some MAS updates may require manual intervention"
|
||||
else
|
||||
echo "✅ All MAS apps are up to date"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ mas not installed - install with: brew install mas"
|
||||
fi
|
||||
|
||||
echo "🔄 Refreshing fzf..."
|
||||
if [ -d ~/.fzf ]; then
|
||||
cd ~/.fzf && git pull && ./install --all && cd -
|
||||
fi
|
||||
|
||||
# Fix Zsh completion security warnings
|
||||
echo "🔒 Checking Zsh completion security..."
|
||||
if [[ -d "/opt/homebrew/share/zsh" ]]; then
|
||||
# Fix common Homebrew Zsh permission issues
|
||||
chmod 755 /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "🧹 Checking for broken symlinks..."
|
||||
find /usr/local/bin "$HOME/bin" "$HOME/.local/bin" -xtype l 2>/dev/null
|
||||
|
||||
echo "🌓 Moon phase at update time:"
|
||||
if command -v curl &>/dev/null && command -v jq >/dev/null; then
|
||||
# Use API key from SwiftBar script
|
||||
local api_key="6ec71a8170214d828c08ba8bf2ca29e9"
|
||||
moon_json=$(curl -s "https://api.ipgeolocation.io/astronomy?apiKey=$api_key" 2>/dev/null)
|
||||
if [[ $? -eq 0 ]] && [[ -n "$moon_json" ]]; then
|
||||
moon_phase=$(echo "$moon_json" | jq -r '.moon_phase // "Unknown"' | tr '_' ' ')
|
||||
illum=$(echo "$moon_json" | jq -r '.moon_illumination_percentage // "Unknown"')
|
||||
# Add moon emoji based on phase
|
||||
local moon_emoji="🌙"
|
||||
case "$moon_phase" in
|
||||
"new moon") moon_emoji="🌑" ;;
|
||||
"waxing crescent") moon_emoji="🌒" ;;
|
||||
"first quarter") moon_emoji="🌓" ;;
|
||||
"waxing gibbous") moon_emoji="🌔" ;;
|
||||
"full moon") moon_emoji="🌕" ;;
|
||||
"waning gibbous") moon_emoji="🌖" ;;
|
||||
"last quarter") moon_emoji="🌗" ;;
|
||||
"waning crescent") moon_emoji="🌘" ;;
|
||||
esac
|
||||
echo "$moon_emoji $moon_phase (${illum}%)"
|
||||
else
|
||||
echo "🌙 Moon phase unavailable"
|
||||
fi
|
||||
else
|
||||
echo "🌙 Moon phase tracking disabled (missing curl or jq)"
|
||||
fi
|
||||
|
||||
if [ -d "$HOME/.dotfiles" ]; then
|
||||
echo "📝 Committing dotfile changes..."
|
||||
cd ~/.dotfiles || return
|
||||
git add . && git commit -m "🔧 Auto-commit from sysupdate on $(date '+%Y-%m-%d %H:%M')" && git push
|
||||
brew bundle dump --force --file="$HOME/.dotfiles/Brewfile"
|
||||
cd - >/dev/null || return
|
||||
fi
|
||||
|
||||
echo "📊 System Info:"
|
||||
echo "💻 $(uname -a)"
|
||||
echo "📅 macOS: $(sw_vers | grep ProductVersion)"
|
||||
echo "🧠 Memory: $(top -l 1 -s 0 | grep PhysMem)"
|
||||
|
||||
# Optional post-update hook
|
||||
if [ -x "$HOME/.zsh/hooks/post-update" ]; then
|
||||
"$HOME/.zsh/hooks/post-update"
|
||||
fi
|
||||
|
||||
echo "🕓 Duration: $(($(date +%s) - $start_time))s"
|
||||
osascript -e 'display notification "Update complete!" with title "System Maintenance" subtitle "All systems go 🚀"'
|
||||
}
|
||||
|
||||
# 💤 Quiet version (no output, same functionality)
|
||||
function quietupdate() {
|
||||
local start_time=$(date +%s)
|
||||
sudo -vn 2>/dev/null || sudo -v
|
||||
sudo softwareupdate -i -a >/dev/null
|
||||
brew update >/dev/null && brew upgrade >/dev/null && brew cleanup >/dev/null && brew autoremove >/dev/null
|
||||
[ -d ~/.fzf ] && cd ~/.fzf && git pull >/dev/null && ./install --all >/dev/null && cd - >/dev/null
|
||||
[ -d "$HOME/.dotfiles" ] && cd ~/.dotfiles && git add . && git commit -m "auto sysupdate" && git push && brew bundle dump --force --file="$HOME/.dotfiles/Brewfile" && cd - >/dev/null
|
||||
if [ -x "$HOME/.zsh/hooks/post-update" ]; then "$HOME/.zsh/hooks/post-update"; fi
|
||||
osascript -e 'display notification "Quiet update complete!" with title "System Maintenance"'
|
||||
}
|
||||
|
||||
## IV. Enhanced Man Page Viewer #######################
|
||||
|
||||
# Detect current terminal for optimal display
|
||||
detect_terminal() {
|
||||
if [[ -n "${KITTY_WINDOW_ID-}" ]]; then
|
||||
echo "kitty"
|
||||
elif [[ -n "${ITERM_SESSION_ID-}" ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||
echo "iterm"
|
||||
elif [[ "$TERM_PROGRAM" == "kitty" ]]; then
|
||||
echo "kitty"
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
# Enhanced man function with beautiful formatting in new window
|
||||
man() {
|
||||
# If no arguments, show usage
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: man <command> [section]"
|
||||
echo "Opens beautifully formatted man page in new terminal window"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local cmd="$1"
|
||||
local section="${2:-}"
|
||||
local terminal_type=$(detect_terminal)
|
||||
|
||||
# Check if man page exists
|
||||
if ! command man -w ${section:+$section} "$cmd" >/dev/null 2>&1; then
|
||||
echo "❌ No manual entry for '$cmd'${section:+ in section $section}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Build the command to run in new window
|
||||
local man_cmd
|
||||
if command -v bat >/dev/null; then
|
||||
# Use bat for beautiful syntax highlighting with Nord theme
|
||||
man_cmd="MANPAGER='bat --language=man --style=grid --color=always --theme=Nord' man ${section:+$section} '$cmd'"
|
||||
else
|
||||
# Fallback to enhanced less
|
||||
man_cmd="MANPAGER='less -R' man ${section:+$section} '$cmd'"
|
||||
fi
|
||||
|
||||
# Terminal-specific window creation
|
||||
case "$terminal_type" in
|
||||
"kitty")
|
||||
# Kitty: New window with optimal size for reading
|
||||
kitty @ new-window --title "📖 man $cmd${section:+ ($section)}" --cwd "$PWD" \
|
||||
zsh -c "$man_cmd; echo; echo '📖 Press any key to close...'; read -k1"
|
||||
;;
|
||||
"iterm")
|
||||
# iTerm2: New window with AppleScript
|
||||
osascript -e "
|
||||
tell application \"iTerm\"
|
||||
create window with default profile
|
||||
tell current session of current window
|
||||
write text \"$man_cmd; echo; echo '📖 Press any key to close...'; read -k1\"
|
||||
set name to \"📖 man $cmd${section:+ ($section)}\"
|
||||
end tell
|
||||
end tell
|
||||
" >/dev/null 2>&1
|
||||
;;
|
||||
*)
|
||||
# Fallback: run in current terminal with nice formatting
|
||||
echo "📖 Displaying man page for '$cmd'${section:+ (section $section)}:"
|
||||
echo ""
|
||||
eval "$man_cmd"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Quick man page search function
|
||||
mans() {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: mans <search_term>"
|
||||
echo "Search for man pages containing the term"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "🔍 Searching man pages for: $*"
|
||||
echo ""
|
||||
|
||||
# Use apropos to search, format nicely
|
||||
if command -v bat >/dev/null; then
|
||||
apropos "$*" | bat --language=man --style=plain --theme=Nord
|
||||
else
|
||||
apropos "$*"
|
||||
fi
|
||||
}
|
||||
|
||||
+208
-379
@@ -2,398 +2,227 @@
|
||||
# ░█▀▀░█░█░█░█░█░░░░█░░░█░░█░█░█░█░▀▀█
|
||||
# ░▀░░░▀▀▀░▀░▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀░▀░▀▀▀
|
||||
|
||||
# Sophisticated shell functions following durability principles
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# I. SYSTEM MAINTENANCE & UPDATES
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Enhanced system update with error handling and rollback capability
|
||||
sysupdate() {
|
||||
local start_time=$(date +%s)
|
||||
local backup_dir="$HOME/.system-snapshots/$(date +%Y%m%d_%H%M%S)"
|
||||
|
||||
echo "🔧 Starting comprehensive system update at $(date)"
|
||||
|
||||
# Ensure sudo credentials and create backup point
|
||||
if ! sudo -vn 2>/dev/null; then
|
||||
echo "🔒 sudo authentication required..."
|
||||
sudo -v || return 1
|
||||
fi
|
||||
|
||||
mkdir -p "$backup_dir"
|
||||
|
||||
# Create restore point
|
||||
echo "💾 Creating system snapshot..."
|
||||
brew list > "$backup_dir/brew_before.txt" 2>/dev/null || true
|
||||
cp "$HOME/.zshrc" "$backup_dir/" 2>/dev/null || true
|
||||
|
||||
# macOS updates with error handling
|
||||
echo "🍎 Updating macOS Software..."
|
||||
if ! sudo softwareupdate -i -a; then
|
||||
echo "⚠️ macOS updates had issues - check manually"
|
||||
fi
|
||||
|
||||
# Homebrew updates with verification
|
||||
echo "🍺 Updating Homebrew packages..."
|
||||
if ! (brew update && brew upgrade); then
|
||||
echo "❌ Homebrew update failed. Restore point: $backup_dir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Mac App Store updates
|
||||
echo "🍎 Updating Mac App Store apps..."
|
||||
if command -v mas >/dev/null; then
|
||||
local mas_outdated=$(mas outdated)
|
||||
if [[ -n "$mas_outdated" ]]; then
|
||||
echo "📱 Updating MAS apps:"
|
||||
echo "$mas_outdated" | while read -r line; do
|
||||
echo " $line"
|
||||
done
|
||||
mas upgrade || echo "⚠️ Some MAS updates may require manual intervention"
|
||||
else
|
||||
echo "✅ All MAS apps are up to date"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ mas not installed - install with: brew install mas"
|
||||
fi
|
||||
|
||||
# Verify critical tools still work
|
||||
local critical_tools=(git zsh python3 brew)
|
||||
for tool in "${critical_tools[@]}"; do
|
||||
if ! command -v "$tool" >/dev/null; then
|
||||
echo "❌ Critical tool $tool missing after update!"
|
||||
echo "🔄 Restore point available: $backup_dir"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Safe cleanup
|
||||
brew cleanup --prune=all
|
||||
brew autoremove
|
||||
|
||||
# Update fzf if present
|
||||
echo "🔄 Refreshing development tools..."
|
||||
if [[ -d ~/.fzf ]]; then
|
||||
(cd ~/.fzf && git pull && ./install --all) >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
# Fix Zsh completion security warnings
|
||||
echo "🔒 Checking Zsh completion security..."
|
||||
if [[ -d "/opt/homebrew/share/zsh" ]]; then
|
||||
# Fix common Homebrew Zsh permission issues
|
||||
chmod 755 /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Check for broken symlinks
|
||||
echo "🧹 Checking for broken symlinks..."
|
||||
local broken_links=$(find "/usr/local/bin" "$HOME/bin" "$HOME/.local/bin" -xtype l 2>/dev/null)
|
||||
[[ -n "$broken_links" ]] && echo "🔗 Broken symlinks found:\n$broken_links"
|
||||
|
||||
# Moon phase logging (using SwiftBar API key)
|
||||
echo "🌓 Celestial context:"
|
||||
if command -v curl >/dev/null && command -v jq >/dev/null; then
|
||||
# Use API key from SwiftBar script
|
||||
local api_key="6ec71a8170214d828c08ba8bf2ca29e9"
|
||||
local moon_json=$(curl -s "https://api.ipgeolocation.io/astronomy?apiKey=$api_key" 2>/dev/null)
|
||||
if [[ $? -eq 0 ]] && [[ -n "$moon_json" ]]; then
|
||||
local moon_phase=$(echo "$moon_json" | jq -r '.moon_phase // "Unknown"' | tr '_' ' ')
|
||||
local illum=$(echo "$moon_json" | jq -r '.moon_illumination_percentage // "Unknown"')
|
||||
# Add moon emoji based on phase
|
||||
local moon_emoji="🌙"
|
||||
case "$moon_phase" in
|
||||
"new moon") moon_emoji="🌑" ;;
|
||||
"waxing crescent") moon_emoji="🌒" ;;
|
||||
"first quarter") moon_emoji="🌓" ;;
|
||||
"waxing gibbous") moon_emoji="🌔" ;;
|
||||
"full moon") moon_emoji="🌕" ;;
|
||||
"waning gibbous") moon_emoji="🌖" ;;
|
||||
"last quarter") moon_emoji="🌗" ;;
|
||||
"waning crescent") moon_emoji="🌘" ;;
|
||||
esac
|
||||
echo "$moon_emoji $moon_phase (${illum}%)"
|
||||
else
|
||||
echo "🌙 Moon phase unavailable"
|
||||
fi
|
||||
else
|
||||
echo "🌙 Moon phase tracking disabled (missing curl or jq)"
|
||||
fi
|
||||
|
||||
# Dotfiles management (corrected path)
|
||||
if [[ -d "$DOTFILES_PATH" ]]; then
|
||||
echo "📝 Syncing dotfiles..."
|
||||
(
|
||||
cd "$DOTFILES_PATH" || return
|
||||
git add .
|
||||
git commit -m "🔧 Auto-commit from sysupdate on $(date '+%Y-%m-%d %H:%M')" 2>/dev/null || true
|
||||
git push 2>/dev/null || true
|
||||
brew bundle dump --force --file="$DOTFILES_PATH/Brewfile" 2>/dev/null || true
|
||||
)
|
||||
fi
|
||||
|
||||
# System information summary
|
||||
echo "📊 System Status:"
|
||||
echo "💻 $(uname -a)"
|
||||
echo "📅 macOS: $(sw_vers -productVersion)"
|
||||
echo "🧠 Memory: $(top -l 1 -s 0 | grep PhysMem | awk '{print $2 " used, " $6 " available"}')"
|
||||
echo "💿 Disk: $(df -h / | tail -1 | awk '{print $3 " used, " $4 " available (" $5 " full)"}')"
|
||||
|
||||
# Post-update hooks
|
||||
if [[ -x "$HOME/.zsh/hooks/post-update" ]]; then
|
||||
echo "🪝 Running post-update hooks..."
|
||||
"$HOME/.zsh/hooks/post-update"
|
||||
fi
|
||||
|
||||
local duration=$(($(date +%s) - start_time))
|
||||
echo "🕓 Update completed in ${duration}s"
|
||||
|
||||
# Success notification
|
||||
if command -v osascript >/dev/null; then
|
||||
osascript -e 'display notification "All systems updated successfully! 🚀" with title "System Maintenance Complete"'
|
||||
fi
|
||||
|
||||
# Cleanup old snapshots (keep last 5)
|
||||
find "$HOME/.system-snapshots" -maxdepth 1 -type d -name "20*" | sort -r | tail -n +6 | xargs rm -rf 2>/dev/null || true
|
||||
## I. PDF Compression #######################
|
||||
pdfcompress ()
|
||||
{
|
||||
gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/screen -dEmbedAllFonts=true -dSubsetFonts=true -dColorImageDownsampleType=/Bicubic -dColorImageResolution=144 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=144 -dMonoImageDownsampleType=/Bicubic -dMonoImageResolution=144 -sOutputFile=$1.compressed.pdf $1;
|
||||
}
|
||||
|
||||
# Quiet version for automated updates
|
||||
quietupdate() {
|
||||
sysupdate >/dev/null 2>&1
|
||||
echo "Silent update completed at $(date)"
|
||||
}
|
||||
## II. Weather #######################
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# II. COMPREHENSIVE SYSTEM CLEANING
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
deep_clean() {
|
||||
echo "🧹 Initiating deep system cleaning..."
|
||||
local cleaned=()
|
||||
|
||||
# DS_Store cleanup
|
||||
local ds_count=$(find "$HOME" -name ".DS_Store" -delete -print 2>/dev/null | wc -l)
|
||||
[[ $ds_count -gt 0 ]] && cleaned+=("$ds_count .DS_Store files")
|
||||
|
||||
# Broken symlinks
|
||||
local broken_symlinks=$(find "$HOME/bin" "$HOME/.local/bin" -xtype l 2>/dev/null)
|
||||
if [[ -n "$broken_symlinks" ]]; then
|
||||
echo "$broken_symlinks" | xargs rm -f
|
||||
local broken_count=$(echo "$broken_symlinks" | wc -l)
|
||||
cleaned+=("$broken_count broken symlinks")
|
||||
fi
|
||||
|
||||
# Cache cleanup
|
||||
local cache_dirs=(
|
||||
"$HOME/Library/Caches/pip"
|
||||
"$HOME/.npm/_cacache"
|
||||
"$HOME/.cache"
|
||||
"$HOME/Library/Caches/Homebrew"
|
||||
)
|
||||
|
||||
for cache_dir in "${cache_dirs[@]}"; do
|
||||
if [[ -d "$cache_dir" ]]; then
|
||||
local cache_size=$(du -sh "$cache_dir" 2>/dev/null | cut -f1)
|
||||
rm -rf "$cache_dir"/* 2>/dev/null || true
|
||||
[[ -n "$cache_size" ]] && cleaned+=("$cache_size from $(basename "$cache_dir") cache")
|
||||
fi
|
||||
done
|
||||
|
||||
# Homebrew cleanup
|
||||
if command -v brew >/dev/null; then
|
||||
local brew_output=$(brew cleanup --prune=all 2>&1)
|
||||
[[ "$brew_output" != *"Nothing to do"* ]] && cleaned+=("Homebrew packages")
|
||||
fi
|
||||
|
||||
# Launch Services cleanup
|
||||
echo "🔄 Rebuilding Launch Services database..."
|
||||
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user 2>/dev/null || true
|
||||
cleaned+=("Launch Services database")
|
||||
|
||||
# Trash cleanup (with confirmation)
|
||||
if [[ -n "$(ls -A ~/.Trash 2>/dev/null)" ]]; then
|
||||
echo -n "🗑️ Empty Trash? (y/N): "
|
||||
read -r response
|
||||
if [[ "$response" =~ ^[Yy]$ ]]; then
|
||||
rm -rf ~/.Trash/* 2>/dev/null || true
|
||||
cleaned+=("Trash contents")
|
||||
fi
|
||||
fi
|
||||
|
||||
# Summary
|
||||
if [[ ${#cleaned[@]} -gt 0 ]]; then
|
||||
echo "✅ Cleaned: ${(j:, :)cleaned}"
|
||||
else
|
||||
echo "✨ System already clean!"
|
||||
fi
|
||||
|
||||
# Final system state
|
||||
echo "💿 Free space: $(df -h / | tail -1 | awk '{print $4}')"
|
||||
}
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# III. VAULT & OBSIDIAN INTEGRATION
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Create or open today's daily note
|
||||
today() {
|
||||
if [[ ! -d "$VAULT_PATH" ]]; then
|
||||
echo "❌ Vault not found at: $VAULT_PATH"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local daily_path="$VAULT_PATH/01. Daily"
|
||||
local today_file="$daily_path/$(date +%Y-%m-%d).md"
|
||||
local template_file="$VAULT_PATH/98. Templates/Daily Note Template.md"
|
||||
|
||||
# Create daily note from template if it doesn't exist
|
||||
if [[ ! -f "$today_file" ]]; then
|
||||
if [[ -f "$template_file" ]]; then
|
||||
cp "$template_file" "$today_file"
|
||||
echo "📝 Created today's daily note"
|
||||
else
|
||||
echo "⚠️ Template not found, creating basic daily note"
|
||||
echo "# $(date +%Y-%m-%d)\n\n## Morning\n\n## Evening\n\n" > "$today_file"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Open in Obsidian
|
||||
if command -v open >/dev/null; then
|
||||
open -a Obsidian "$today_file"
|
||||
else
|
||||
echo "📍 Daily note: $today_file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Quick vault search with fzf
|
||||
vf() {
|
||||
if [[ ! -d "$VAULT_PATH" ]]; then
|
||||
echo "❌ Vault not found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! command -v fzf >/dev/null; then
|
||||
echo "❌ fzf not available"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local file
|
||||
file=$(find "$VAULT_PATH" -name "*.md" -not -path "*/.*" | \
|
||||
sed "s|$VAULT_PATH/||" | \
|
||||
fzf --preview "head -20 '$VAULT_PATH/{}'" \
|
||||
--preview-window=right:60% \
|
||||
--header="Select vault file to open")
|
||||
|
||||
if [[ -n "$file" ]]; then
|
||||
open -a Obsidian "$VAULT_PATH/$file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Weekly review creation
|
||||
weekly() {
|
||||
local week_num=$(date +%U)
|
||||
local year=$(date +%Y)
|
||||
local weekly_file="$VAULT_PATH/02. Reviews & Planning/${year}-W${week_num}.md"
|
||||
local template_file="$VAULT_PATH/98. Templates/Weekly_Review_Template.md"
|
||||
|
||||
if [[ ! -f "$weekly_file" ]] && [[ -f "$template_file" ]]; then
|
||||
cp "$template_file" "$weekly_file"
|
||||
echo "📅 Created weekly review for week $week_num"
|
||||
fi
|
||||
|
||||
open -a Obsidian "$weekly_file" 2>/dev/null || echo "📍 Weekly review: $weekly_file"
|
||||
}
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# IV. CHAMBER & WORKFLOW INTEGRATION
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Chamber mode switching
|
||||
chamber() {
|
||||
local mode="${1:-unified}"
|
||||
local mode_file="$CHAMBER_PATH/docs/chamber/workflow/MODE-${mode^^}.md"
|
||||
|
||||
if [[ -f "$mode_file" ]]; then
|
||||
open "$mode_file" 2>/dev/null || echo "📍 Chamber mode: $mode_file"
|
||||
cd "$CHAMBER_PATH" 2>/dev/null || true
|
||||
export CURRENT_CONTEXT="chamber"
|
||||
else
|
||||
echo "❌ Chamber mode '$mode' not found"
|
||||
echo "Available modes:"
|
||||
ls "$CHAMBER_PATH/docs/chamber/workflow/MODE-"*.md 2>/dev/null | \
|
||||
sed 's/.*MODE-\(.*\)\.md/\1/' | tr '[:upper:]' '[:lower:]' || echo "None found"
|
||||
fi
|
||||
}
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
# V. UTILITY FUNCTIONS
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Enhanced weather function
|
||||
wttr() {
|
||||
local location=${1:-}
|
||||
local format=${2:-"?n"} # Default to narrow format
|
||||
|
||||
if command -v curl >/dev/null; then
|
||||
curl -s "wttr.in/${location}${format}"
|
||||
# Usage: wttr [location]
|
||||
# Examples: wttr -> your IP-based location
|
||||
# wttr 75012 -> Paris 12e
|
||||
# wttr 23190 -> Crozant
|
||||
local location=${1:-}
|
||||
curl -s "wttr.in/${location}?n"
|
||||
}
|
||||
|
||||
## III. Updates (system, brew, etc) #######################
|
||||
## Description: Performs system updates, Homebrew cleanup, fzf refresh, moon phase logging, and dotfile sync ###########################
|
||||
|
||||
function sysupdate() {
|
||||
local start_time=$(date +%s)
|
||||
echo "🔧 Starting full system update at $(date)"
|
||||
|
||||
# Ensure sudo credentials are fresh
|
||||
if ! sudo -vn 2>/dev/null; then
|
||||
echo "🔒 sudo authentication required..."
|
||||
sudo -v
|
||||
fi
|
||||
|
||||
echo "🍎 Updating macOS Software..."
|
||||
sudo softwareupdate -i -a
|
||||
|
||||
echo "🍺 Updating Homebrew packages..."
|
||||
brew update
|
||||
brew upgrade
|
||||
brew cleanup
|
||||
brew autoremove
|
||||
|
||||
# Mac App Store updates
|
||||
echo "🍎 Updating Mac App Store apps..."
|
||||
if command -v mas >/dev/null; then
|
||||
local mas_outdated=$(mas outdated)
|
||||
if [[ -n "$mas_outdated" ]]; then
|
||||
echo "📱 Updating MAS apps:"
|
||||
echo "$mas_outdated" | while read -r line; do
|
||||
echo " $line"
|
||||
done
|
||||
mas upgrade || echo "⚠️ Some MAS updates may require manual intervention"
|
||||
else
|
||||
echo "❌ curl not available for weather lookup"
|
||||
echo "✅ All MAS apps are up to date"
|
||||
fi
|
||||
}
|
||||
else
|
||||
echo "⚠️ mas not installed - install with: brew install mas"
|
||||
fi
|
||||
|
||||
# PDF compression with quality options
|
||||
pdfcompress() {
|
||||
local input_file="$1"
|
||||
local quality="${2:-screen}" # screen, ebook, printer, prepress
|
||||
|
||||
if [[ ! -f "$input_file" ]]; then
|
||||
echo "❌ File not found: $input_file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! command -v gs >/dev/null; then
|
||||
echo "❌ Ghostscript not found. Install with: brew install ghostscript"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local output_file="${input_file%.*}.compressed.pdf"
|
||||
|
||||
gs -q -dNOPAUSE -dBATCH -dSAFER \
|
||||
-sDEVICE=pdfwrite \
|
||||
-dCompatibilityLevel=1.4 \
|
||||
-dPDFSETTINGS=/"$quality" \
|
||||
-dEmbedAllFonts=true \
|
||||
-dSubsetFonts=true \
|
||||
-sOutputFile="$output_file" \
|
||||
"$input_file"
|
||||
|
||||
if [[ -f "$output_file" ]]; then
|
||||
local original_size=$(du -h "$input_file" | cut -f1)
|
||||
local compressed_size=$(du -h "$output_file" | cut -f1)
|
||||
echo "✅ Compressed: $original_size → $compressed_size"
|
||||
echo "📍 Output: $output_file"
|
||||
echo "🔄 Refreshing fzf..."
|
||||
if [ -d ~/.fzf ]; then
|
||||
cd ~/.fzf && git pull && ./install --all && cd -
|
||||
fi
|
||||
|
||||
# Fix Zsh completion security warnings
|
||||
echo "🔒 Checking Zsh completion security..."
|
||||
if [[ -d "/opt/homebrew/share/zsh" ]]; then
|
||||
# Fix common Homebrew Zsh permission issues
|
||||
chmod 755 /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "🧹 Checking for broken symlinks..."
|
||||
find /usr/local/bin "$HOME/bin" "$HOME/.local/bin" -xtype l 2>/dev/null
|
||||
|
||||
echo "🌓 Moon phase at update time:"
|
||||
if command -v curl &>/dev/null && command -v jq >/dev/null; then
|
||||
# Use API key from SwiftBar script
|
||||
local api_key="6ec71a8170214d828c08ba8bf2ca29e9"
|
||||
moon_json=$(curl -s "https://api.ipgeolocation.io/astronomy?apiKey=$api_key" 2>/dev/null)
|
||||
if [[ $? -eq 0 ]] && [[ -n "$moon_json" ]]; then
|
||||
moon_phase=$(echo "$moon_json" | jq -r '.moon_phase // "Unknown"' | tr '_' ' ')
|
||||
illum=$(echo "$moon_json" | jq -r '.moon_illumination_percentage // "Unknown"')
|
||||
# Add moon emoji based on phase
|
||||
local moon_emoji="🌙"
|
||||
case "$moon_phase" in
|
||||
"new moon") moon_emoji="🌑" ;;
|
||||
"waxing crescent") moon_emoji="🌒" ;;
|
||||
"first quarter") moon_emoji="🌓" ;;
|
||||
"waxing gibbous") moon_emoji="🌔" ;;
|
||||
"full moon") moon_emoji="🌕" ;;
|
||||
"waning gibbous") moon_emoji="🌖" ;;
|
||||
"last quarter") moon_emoji="🌗" ;;
|
||||
"waning crescent") moon_emoji="🌘" ;;
|
||||
esac
|
||||
echo "$moon_emoji $moon_phase (${illum}%)"
|
||||
else
|
||||
echo "❌ Compression failed"
|
||||
echo "🌙 Moon phase unavailable"
|
||||
fi
|
||||
else
|
||||
echo "🌙 Moon phase tracking disabled (missing curl or jq)"
|
||||
fi
|
||||
|
||||
if [ -d "$HOME/.dotfiles" ]; then
|
||||
echo "📝 Committing dotfile changes..."
|
||||
cd ~/.dotfiles || return
|
||||
git add . && git commit -m "🔧 Auto-commit from sysupdate on $(date '+%Y-%m-%d %H:%M')" && git push
|
||||
brew bundle dump --force --file="$HOME/.dotfiles/Brewfile"
|
||||
cd - >/dev/null || return
|
||||
fi
|
||||
|
||||
echo "📊 System Info:"
|
||||
echo "💻 $(uname -a)"
|
||||
echo "📅 macOS: $(sw_vers | grep ProductVersion)"
|
||||
echo "🧠 Memory: $(top -l 1 -s 0 | grep PhysMem)"
|
||||
|
||||
# Optional post-update hook
|
||||
if [ -x "$HOME/.zsh/hooks/post-update" ]; then
|
||||
"$HOME/.zsh/hooks/post-update"
|
||||
fi
|
||||
|
||||
echo "🕓 Duration: $(($(date +%s) - $start_time))s"
|
||||
osascript -e 'display notification "Update complete!" with title "System Maintenance" subtitle "All systems go 🚀"'
|
||||
}
|
||||
|
||||
# 💤 Quiet version (no output, same functionality)
|
||||
function quietupdate() {
|
||||
local start_time=$(date +%s)
|
||||
sudo -vn 2>/dev/null || sudo -v
|
||||
sudo softwareupdate -i -a >/dev/null
|
||||
brew update >/dev/null && brew upgrade >/dev/null && brew cleanup >/dev/null && brew autoremove >/dev/null
|
||||
[ -d ~/.fzf ] && cd ~/.fzf && git pull >/dev/null && ./install --all >/dev/null && cd - >/dev/null
|
||||
[ -d "$HOME/.dotfiles" ] && cd ~/.dotfiles && git add . && git commit -m "auto sysupdate" && git push && brew bundle dump --force --file="$HOME/.dotfiles/Brewfile" && cd - >/dev/null
|
||||
if [ -x "$HOME/.zsh/hooks/post-update" ]; then "$HOME/.zsh/hooks/post-update"; fi
|
||||
osascript -e 'display notification "Quiet update complete!" with title "System Maintenance"'
|
||||
}
|
||||
|
||||
## IV. Enhanced Man Page Viewer #######################
|
||||
|
||||
# Detect current terminal for optimal display
|
||||
detect_terminal() {
|
||||
if [[ -n "${KITTY_WINDOW_ID-}" ]]; then
|
||||
echo "kitty"
|
||||
elif [[ -n "${ITERM_SESSION_ID-}" ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||
echo "iterm"
|
||||
elif [[ "$TERM_PROGRAM" == "kitty" ]]; then
|
||||
echo "kitty"
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
# Enhanced man function with beautiful formatting in new window
|
||||
man() {
|
||||
# If no arguments, show usage
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: man <command> [section]"
|
||||
echo "Opens beautifully formatted man page in new terminal window"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Context-aware directory change with hooks
|
||||
smart_cd() {
|
||||
cd "$@" && detect_context
|
||||
|
||||
# Auto-activate virtual environments
|
||||
if [[ -f "venv/bin/activate" ]]; then
|
||||
echo "🐍 Virtual environment detected"
|
||||
local cmd="$1"
|
||||
local section="${2:-}"
|
||||
local terminal_type=$(detect_terminal)
|
||||
|
||||
# Check if man page exists
|
||||
if ! command man -w ${section:+$section} "$cmd" >/dev/null 2>&1; then
|
||||
echo "❌ No manual entry for '$cmd'${section:+ in section $section}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Show git status in git repos
|
||||
if [[ -d ".git" ]] && command -v git >/dev/null; then
|
||||
echo "📊 $(git branch --show-current) | $(git status --porcelain | wc -l | tr -d ' ') changes"
|
||||
# Build the command to run in new window
|
||||
local man_cmd
|
||||
if command -v bat >/dev/null; then
|
||||
# Use bat for beautiful syntax highlighting with Nord theme
|
||||
man_cmd="MANPAGER='bat --language=man --style=grid --color=always --theme=Nord' man ${section:+$section} '$cmd'"
|
||||
else
|
||||
# Fallback to enhanced less
|
||||
man_cmd="MANPAGER='less -R' man ${section:+$section} '$cmd'"
|
||||
fi
|
||||
|
||||
# Terminal-specific window creation
|
||||
case "$terminal_type" in
|
||||
"kitty")
|
||||
# Kitty: New window with optimal size for reading
|
||||
kitty @ new-window --title "📖 man $cmd${section:+ ($section)}" --cwd "$PWD" \
|
||||
zsh -c "$man_cmd; echo; echo '📖 Press any key to close...'; read -k1"
|
||||
;;
|
||||
"iterm")
|
||||
# iTerm2: New window with AppleScript
|
||||
osascript -e "
|
||||
tell application \"iTerm\"
|
||||
create window with default profile
|
||||
tell current session of current window
|
||||
write text \"$man_cmd; echo; echo '📖 Press any key to close...'; read -k1\"
|
||||
set name to \"📖 man $cmd${section:+ ($section)}\"
|
||||
end tell
|
||||
end tell
|
||||
" >/dev/null 2>&1
|
||||
;;
|
||||
*)
|
||||
# Fallback: run in current terminal with nice formatting
|
||||
echo "📖 Displaying man page for '$cmd'${section:+ (section $section)}:"
|
||||
echo ""
|
||||
eval "$man_cmd"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Quick man page search function
|
||||
mans() {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: mans <search_term>"
|
||||
echo "Search for man pages containing the term"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "🔍 Searching man pages for: $*"
|
||||
echo ""
|
||||
|
||||
# Use apropos to search, format nicely
|
||||
if command -v bat >/dev/null; then
|
||||
apropos "$*" | bat --language=man --style=plain --theme=Nord
|
||||
else
|
||||
apropos "$*"
|
||||
fi
|
||||
}
|
||||
|
||||
# Override cd with smart_cd
|
||||
alias cd='smart_cd'
|
||||
|
||||
# Add context detection to prompt changes
|
||||
chpwd_functions+=(detect_context)
|
||||
+4
-1
@@ -5,7 +5,10 @@
|
||||
# Intelligent PATH management with existence checking and deduplication
|
||||
|
||||
# Ensure we have a clean slate for PATH manipulation
|
||||
typeset -U path PATH # Remove duplicates automatically
|
||||
# Remove duplicates automatically (zsh-specific)
|
||||
if [[ -n "$ZSH_VERSION" ]]; then
|
||||
typeset -U path PATH
|
||||
fi
|
||||
|
||||
# Define potential paths in priority order
|
||||
declare -a potential_paths=(
|
||||
|
||||
Reference in New Issue
Block a user