config

#brew#nushell

git clone https://git.pyrossh.dev/config

Common configuration


zshrc
export XDG_CONFIG_HOME="/Users/pyrossh/Code/config"
export EDITOR="hx"

launchctl setenv XDG_CONFIG_HOME "$XDG_CONFIG_HOME"
launchctl setenv ANDROID_HOME ~/Library/Android/sdk
launchctl setenv EDITOR "$EDITOR"

launchctl setenv PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin

source /opt/homebrew/share/antigen/antigen.zsh

antigen use oh-my-zsh

antigen bundle git
antigen bundle command-not-found
antigen bundle docker
antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-history-substring-search

antigen apply

# =============================================================================
# History (nushell: max_size 1_000_000, sync_on_enter -> oh-my-zsh share_history)
# =============================================================================
HISTSIZE=1000000
SAVEHIST=1000000

# =============================================================================
# Line editor (nushell: edit_mode emacs + reedline keybindings that differ
# from zsh/oh-my-zsh defaults)
# =============================================================================
bindkey -e
autoload -Uz edit-command-line
zle -N edit-command-line
bindkey '^O' edit-command-line                # open_command_editor
bindkey '^Z' undo                             # undo_change
bindkey '^G' redo                             # redo_change
bindkey '^U' backward-kill-line               # cut_line_from_start
bindkey '^Q' history-incremental-search-backward  # search_history
bindkey '^P' up-line-or-beginning-search      # move_up (same as Up)
bindkey '^N' down-line-or-beginning-search    # move_down (same as Down)
bindkey '^[[1;3D' backward-word               # alt+left
bindkey '^[[1;3C' forward-word                # alt+right
bindkey '^[[3;3~' kill-word                   # alt+delete
bindkey '^[[3;5~' delete-char                 # ctrl+delete
bindkey '^[m' backward-kill-word              # alt+m

alias ls="eza -la --icons --hyperlink --git"

# Source Cargo environment
if [ -f "$HOME/.cargo/env" ]; then
    source "$HOME/.cargo/env"
fi

# =============================================================================
# Custom Functions
# =============================================================================

repo-push() {
    # Check if we are at the git repo root
    local root
    root=$(git rev-parse --show-toplevel 2>/dev/null | xargs)
    
    if [[ "$root" != "$(pwd)" ]]; then
        echo "Error: must be run from the git repo root directory" >&2
        return 1
    fi
    
    git gc --prune=now
    git repack -a -d -f --depth=250 --window=250
    git update-server-info
    
    local repo_name
    repo_name=$(basename "$(pwd)")
    
    rclone sync --http-headers '"Content-Type","application/octet-stream"' .git "git:git/$repo_name" --checksum --fast-list --multi-thread-streams=32 -P
}

backup-git() {
    rclone sync git:git "/Volumes/SSD T7/git" --checksum --fast-list --multi-thread-streams=32 -P
}

backup-website() {
    rclone sync website:website "/Volumes/SSD T7/website" --checksum --fast-list --multi-thread-streams=32 -P
}


# =============================================================================
# Environment Variables
# =============================================================================
export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/opt/homebrew/share/zsh-syntax-highlighting/highlighters
export JAVA_HOME="/opt/homebrew/opt/openjdk@17"
export ANDROID_HOME="/Users/pyrossh/Library/Android/sdk"
export ANDROID_SDK_ROOT="/Users/pyrossh/Library/Android/sdk"
export ANDROID_NDK_ROOT="/Users/pyrossh/Library/Android/sdk/ndk/29.0.13113456"
export ANDROID_NDK_HOME="/Users/pyrossh/Library/Android/sdk/ndk/29.0.13113456"

# =============================================================================
# PATH Configuration
# =============================================================================
# Zsh ties the $PATH string to the $path array. 
# We can append elements to the array for a much cleaner look than string chaining.
path=(
  /opt/homebrew/bin
  /opt/homebrew/opt/openjdk@17/bin
  /opt/homebrew/opt/ruby/bin
  /opt/homebrew/opt/curl/bin
  $HOME/.cargo/bin
  $HOME/.pub-cache/bin
  $HOME/Library/Android/sdk/emulator
  $HOME/Library/Android/sdk/platform-tools
  $HOME/.dotnet
  $HOME/.dotnet/tools
  $HOME/.local/bin
  /usr/local/bin
  $(brew --prefix llvm)/bin
  $path
)
export PATH

# =============================================================================
# Prompt (Oh My Posh)
# =============================================================================
# Initialize Oh My Posh using your specific theme
if command -v oh-my-posh &> /dev/null; then
  eval "$(oh-my-posh init zsh --config /opt/homebrew/opt/oh-my-posh/themes/zash.omp.json)"
fi

# nushell PROMPT_INDICATOR: yellow "$> " after the oh-my-posh prompt.
# Must run after oh-my-posh's precmd, which rebuilds PS1 every prompt.
# Also sets nushell's emacs cursor_shape (line) via DECSCUSR.
_nu_prompt_indicator() {
  PS1+='%F{yellow}$> %f'
  print -n '\e[6 q'
}
(( ${precmd_functions[(I)_nu_prompt_indicator]} )) || precmd_functions+=(_nu_prompt_indicator)