# Core Zsh settings HISTSIZE=5000000 HISTFILE=~/.zsh_history SAVEHIST=$HISTSIZE setopt EXTENDED_HISTORY APPEND_HISTORY SHARE_HISTORY HIST_IGNORE_SPACE setopt HIST_IGNORE_ALL_DUPS HIST_SAVE_NO_DUPS HIST_IGNORE_DUPS HIST_FIND_NO_DUPS setopt AUTOCD # Keybindings bindkey -e bindkey '^p' history-search-backward bindkey '^n' history-search-forward bindkey '^[w' kill-region # Completion styling zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" zstyle ':completion:*' menu no zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath' zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath' zstyle ':completion:*' range 1000:100 # Path Management (Linux specific from your original file) # This assumes your main environment is Linux given the path elements. # If this is a dual-boot or you frequently switch OS, # you might need to adjust the PATH logic further. if [[ $(uname) == "Linux" ]]; then # Ensure /usr/local/bin is at the front PATH="/usr/local/bin:$PATH" # Google Cloud SDK PATH and completion if [ -f '/home/errol/google-cloud-sdk/path.zsh.inc' ]; then . '/home/errol/google-cloud-sdk/path.zsh.inc' fi if [ -f '/home/errol/google-cloud-sdk/completion.zsh.inc' ]; then . '/home/errol/google-cloud-sdk/completion.zsh.inc' fi # Krew (Kubernetes plugin manager) export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" # Google Application Credentials export GOOGLE_APPLICATION_CREDENTIALS=/Users/errol/.config/gcloud/application_default_credentials.json # Alacritty config setup alacritty_config_setup linux fi # Homebrew setup (for macOS and Linuxbrew) if [[ -f "/opt/homebrew/bin/brew" ]]; then eval "$(/opt/homebrew/bin/brew shellenv)" export HOMEBREW_NO_ENV_HINTS=1 # Function to ensure Homebrew packages are installed function ensure_brew_packages { local packages=("$@") local cellar_dir="/opt/homebrew/Cellar" local caskroom_dir="/opt/homebrew/Caskroom" for package in "${packages[@]}"; do if ! [[ -d "$cellar_dir/$package" || -d "$caskroom_dir/$package" ]]; then echo "Installing $package..." if brew info --cask "$package" &>/dev/null; then brew install --cask --force "$package" else brew install --force "$package" fi fi done } # List of Homebrew packages to ensure are installed brew_packages=( "opentofu" "docker" "docker-completion" "helm" "ipython" "jq" "k9s" "kubernetes-cli" "neovim" "nmap" "stow" "terragrunt" "tmux" "font-hack-nerd-font" "alacritty" "spotify" "tailscale" "visual-studio-code" "fzf" "ripgrep" "fd" "spotify_player" ) ensure_brew_packages "${brew_packages[@]}" fi # Alacritty config setup (for macOS) if [[ $(uname) == "Darwin" ]]; then alacritty_config_setup osx fi # Shell start display function shell_start_disp { echo -n "$(hostname) - " if command -v ifconfig &>/dev/null; then # Use command -v for portability ifconfig | awk '/inet / && !/inet6/ && !/127.0.0.1/ {ips = ips " " $2} END {print ips}' elif command -v ip &>/dev/null; then # Fallback for systems without ifconfig ip -4 addr show | awk '/inet / && !/127.0.0.1/ {print $2}' | cut -d/ -f1 | tr '\n' ' ' fi echo # Add a newline to separate prompt from output } shell_start_disp # Load aliases and Google specific configurations if [[ -r ~/.aliasrc ]]; then . ~/.aliasrc fi if [[ -r ~/.google_rc ]]; then . ~/.google_rc fi # Fuzzy search history function fh() { eval $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//') } # History search function (fixes the grep issue by using \grep) function h() { if [ -z "$*" ]; then history 1 else history 1 | \grep --color=auto "$@" # Use \grep to avoid alias recursion fi } # Starship prompt if command -v starship &> /dev/null; then eval "$(starship init zsh)" else # Simplified installation, assumes curl is available and interactive script is okay # You might want to make this non-interactive or pre-download in a production setup curl -sS https://starship.rs/install.sh | sh fi # tmux plugin manager if [[ ! -d ~/.tmux/plugins/tpm ]]; then git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm fi # Gam alias alias gam="/home/errol/bin/gamadv-xtd3/gam" # Kubectl completion if command -v kubectl &> /dev/null; then source <(kubectl completion zsh) fi # --- Helper Functions (defined at the end for clarity) --- # Function to setup Alacritty configuration function alacritty_config_setup { if [[ -f "$HOME/.config/alacritty/alacritty-base.toml" ]]; then local toml_files=("$HOME/.config/alacritty/alacritty-base.toml" "$HOME/.config/alacritty/alacritty-$1.toml") local combined_file="$HOME/.config/alacritty/alacritty.toml" echo -n > "$combined_file" for file in "${toml_files[@]}"; do if [ -f "$file" ]; then cat "$file" >> "$combined_file" echo >> "$combined_file" # Add newline else echo "File '$file' not found. Skipping." fi done fi }