if command -v nvim >/dev/null 2>&1; then
  export EDITOR=nvim
  export PAGER="nvim +Man!"
  export MANPAGER="nvim +Man!"
elif command -v vim >/dev/null 2>&1; then
  export EDITOR=vim
elif command -v vi >/dev/null 2>&1; then
  export EDITOR=vi
fi

if [ -d "$HOME/workspace/github.com/git/git/contrib/" ]; then
	export _GIT_CONTRIB="$HOME/workspace/github.com/git/git/contrib/"
elif [ -d /opt/homebrew/share/git-core/contrib/ ]; then
	export _GIT_CONTRIB='/opt/homebrew/share/git-core/contrib/'
elif [ -d /usr/local/share/git/contrib/ ]; then
	export _GIT_CONTRIB='/usr/local/share/git/contrib/'
fi

if [ -d "${_GIT_CONTRIB:-}" ]; then
  export GITPAGER="${_GIT_CONTRIB}diff-highlight/diff-highlight | less -RFX"
else
  export GITPAGER="less -RFX"
fi

if [ "${TERM_PROGRAM:-}" = "vscode" ]; then
  if [ "${TERM_PRODUCT:-}" = "Trae" ]; then
    IS_TRAE=1
  fi
  if [ "${IS_TRAE:-0}" = 1 ]; then
    if command -v trae >/dev/null 2>&1; then
      export EDITOR="trae --wait -"
      alias code=trae
    elif command -v trae-cn >/dev/null 2>&1; then
      export EDITOR="trae-cn --wait -"
    fi
  else
    export EDITOR="code --wait -"
  fi

  #export GIT_PAGER="$EDITOR" # this looks terrible

  export GIT_CONFIG_COUNT=3
  export GIT_CONFIG_KEY_0="diff.tool"
  export GIT_CONFIG_VALUE_0="vscode"
  export GIT_CONFIG_KEY_1="merge.tool"
  export GIT_CONFIG_VALUE_1="vscode"
  export GIT_CONFIG_KEY_2="color.pager"
  export GIT_CONFIG_VALUE_2="false"
fi


export RIPGREP_CONFIG_PATH="$HOME/.config/ripgrep/rgignore"
export FD_CONFIG_PATH="$HOME/.config/fd/fdignore"

if [ -d /opt/homebrew/bin ]; then
  export HOMEBREW_PREFIX="/opt/homebrew";
  export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
  export HOMEBREW_REPOSITORY="/opt/homebrew";
fi

if type copilot > /dev/null 2>&1; then
  export COPILOT_CUSTOM_INSTRUCTIONS_DIRS="$HOME/.config/copilot/"
fi

# use production database for opencode even when running self-built version
export OPENCODE_DB=opencode.db

[ -r "$HOME/.secrets.env" ] && . "$HOME/.secrets.env"

# show Sapling changed/modified files in prompt
#export SHOW_DIRTY_STATE=1


#vpn
#export http_proxy=http://sysproxy.wal-mart.com:8080
#export https_proxy=https://walmart.zoom.us/j/96619946927?from=addon
#export no_proxy='*.wal-mart.com,*.walmart.net,*.walmart.com,localhost,127.0.0.1'

[ -r "$HOME/.paths.sh" ] && . "$HOME/.paths.sh"
