# Zsh History Configuration
# Add this to your ~/.zshrc file

# ============================================
# HISTORY FILE LOCATION
# ============================================

HISTFILE=~/.zsh_history

# ============================================
# HISTORY SIZE CONFIGURATION
# ============================================

# Number of commands to remember in memory
HISTSIZE=50000

# Number of commands to save in history file
SAVEHIST=100000

# ============================================
# HISTORY OPTIONS
# ============================================

# Write timestamp to history file
setopt EXTENDED_HISTORY

# Expire duplicate entries first when trimming history
setopt HIST_EXPIRE_DUPS_FIRST

# Don't record an entry that was just recorded again
setopt HIST_IGNORE_DUPS

# Delete old recorded entry if new entry is a duplicate
setopt HIST_IGNORE_ALL_DUPS

# Don't write duplicate entries in the history file
setopt HIST_SAVE_NO_DUPS

# Remove superfluous blanks before recording entry
setopt HIST_REDUCE_BLANKS

# Don't execute immediately upon history expansion
setopt HIST_VERIFY

# Share history between all sessions
setopt SHARE_HISTORY

# Don't record commands starting with space
setopt HIST_IGNORE_SPACE

# ============================================
# OPTIONAL: UNLIMITED HISTORY
# ============================================

# Uncomment for unlimited history (use with caution)
# HISTSIZE=1000000000
# SAVEHIST=1000000000

# ============================================
# HISTORY SEARCH
# ============================================

# Bind up/down arrow keys to history search
bindkey '^[[A' history-beginning-search-backward
bindkey '^[[B' history-beginning-search-forward

# ============================================
# CUSTOM HISTORY COMMANDS
# ============================================

# Alias for viewing history with timestamps
alias hist='fc -li 1'

# Alias for searching history
alias hgrep='history | grep'
