export PATH="$HOME/.local/share/nvim/mason/bin:$PATH"
export PATH="$PATH:/home/jonas/.local/bin"

# History configuration
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000

setopt APPEND_HISTORY          # Append history instead of overwriting
setopt EXTENDED_HISTORY         # Save timestamps
setopt HIST_FIND_NO_DUPS       # Don't show duplicates when searching
setopt HIST_IGNORE_DUPS        # Don't save duplicate commands
setopt HIST_IGNORE_SPACE       # Don't save commands starting with space
setopt INC_APPEND_HISTORY      # Write to history immediately, not at shell exit
setopt SHARE_HISTORY           # Share history between sessions

# Completion
autoload -U compinit && compinit
zmodload zsh/complist

zstyle ':completion:*' menu select                        # show menu, highlight selection
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}    # file-type colors (dirs, executables, etc.)
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # case-insensitive matching

# Plugins
source ~/.zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
source ~/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
source ~/.zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.plugin.zsh

# zsh-history-substring-search key bindings
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down

unsetopt autocd

alias hooknloop='godot --display-driver wayland --rendering-driver opengl3 ~/shared/godot-projects/hooknloop/project.godot'
alias screengrab='hyprshot -m region --clipboard-only'
alias claude-work="CLAUDE_WORK=1 CLAUDE_CONFIG_DIR=~/.claude-work claude"
alias qwen-local='QWEN_CODE_AUTH_TYPE=openai-compatible QWEN_CODE_API_KEY=llama-cpp QWEN_CODE_BASE_URL=http://127.0.0.1:8080/v1 qwen'

export EDITOR="nvim"
export VISUAL="nvim"
export SUDO_EDITOR="nvim"
export OPENROUTER_API_KEY=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
export ZAI_API_KEY=80a53d7e46724e9aa913b06e1f8fa4f0.Yeq45xsosX3LfWxk
export USE_BUILTIN_RIPGREP=0
export REAL_DEBRID_API_KEY="HQVUOC3ALUHIIQCFQK4UOV2GVGVLQKKHEWFWKN77G6URFBTQMUTQ"
export HF_TOKEN=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
export OPENCODE_API_KEY=sk-oU07900FhkKHUSpwEI8SiWjoZmV2kg8TUhVwfRWcPOjaHHq8b0dCPrb1PQNuLnh0

export PATH=~/.npm-global/bin:$PATH

export LD_LIBRARY_PATH=/home/jonas/.local/lib64:$LD_LIBRARY_PATH

function y() {
	local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
	yazi "$@" --cwd-file="$tmp"
	IFS= read -r -d '' cwd < "$tmp"
	[ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd"
	rm -f -- "$tmp"
}

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init - zsh)"

eval "$(starship init zsh)"
eval "$(zoxide init zsh)"

if command -v tmux &>/dev/null && [ -z "$TMUX" ]; then
  if [ -n "$SSH_CONNECTION" ] || [ -n "$MOSH_SOCK" ]; then
    tmux new-session -As moshi
  fi
fi   
