Initial commit: Complete macOS dotfiles system
🖖 Features: - Master 'engage' script for one-command setup - 120+ CLI tools via Homebrew - 40+ Applications (casks + MAS apps) - Complete macOS system configuration - Security hardening and privacy settings - Obsidian knowledge vault setup - Comprehensive backup strategies - Automated symlink management Live long and prosper\! 🚀 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env zsh
|
||||
# Shell history synchronization for dotfiles
|
||||
# Add this to your .zshrc
|
||||
|
||||
# History configuration
|
||||
export HISTFILE="$HOME/.zsh_history"
|
||||
export HISTSIZE=100000
|
||||
export SAVEHIST=100000
|
||||
|
||||
# Better history behavior
|
||||
setopt EXTENDED_HISTORY # Write timestamp to history
|
||||
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicates first
|
||||
setopt HIST_IGNORE_DUPS # Don't record duplicates
|
||||
setopt HIST_IGNORE_SPACE # Don't record commands starting with space
|
||||
setopt HIST_VERIFY # Show command before executing from history
|
||||
setopt INC_APPEND_HISTORY # Add commands immediately
|
||||
setopt SHARE_HISTORY # Share history between sessions
|
||||
|
||||
# Create a backup of history on each new session
|
||||
if [[ -f "$HISTFILE" ]]; then
|
||||
HIST_BACKUP_DIR="$HOME/.history_backups"
|
||||
mkdir -p "$HIST_BACKUP_DIR"
|
||||
|
||||
# Keep daily backups for the last 7 days
|
||||
cp "$HISTFILE" "$HIST_BACKUP_DIR/zsh_history_$(date +%Y%m%d)"
|
||||
|
||||
# Clean up old backups (keep last 7 days)
|
||||
find "$HIST_BACKUP_DIR" -name "zsh_history_*" -mtime +7 -delete 2>/dev/null
|
||||
fi
|
||||
|
||||
# Function to sync history to dotfiles (call manually)
|
||||
history_checkpoint() {
|
||||
local dotfiles_history="$HOME/dotfiles/shell/zsh_history_checkpoint"
|
||||
if [[ -f "$HISTFILE" ]]; then
|
||||
# Keep last 10000 commands as checkpoint
|
||||
tail -n 10000 "$HISTFILE" > "$dotfiles_history"
|
||||
echo "History checkpoint saved to dotfiles"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to search all history including backups
|
||||
history_search_all() {
|
||||
local pattern="$1"
|
||||
echo "Searching current history..."
|
||||
history | grep -i "$pattern"
|
||||
|
||||
echo -e "\nSearching history backups..."
|
||||
find "$HOME/.history_backups" -name "zsh_history_*" -exec grep -H -i "$pattern" {} \;
|
||||
}
|
||||
Reference in New Issue
Block a user