#
# {{@@ header() @@}}
#


# Fix for JetBrains with non-re-parenting window managers
export _JAVA_AWT_WM_NONREPARENTING=1
# Disable Ansible cowsay
export ANSIBLE_NOCOWS=1

# Include ~/.local/bin to PATH
[[ -d "{{@@ env['HOME'] @@}}/.local/bin" ]] && export PATH="{{@@ env['HOME'] @@}}/.local/bin:${PATH}"

# Include krew to PATH
[[ -d "{{@@ env['HOME'] @@}}/.krew/bin" ]] && export PATH="{{@@ env['HOME'] @@}}/.krew/bin:${PATH}"

{%@@ if distro == 'macos' @@%}# Include /opt/homebrew/opt/gnu-getopt/bin to PATH
[[ -d "/opt/homebrew/opt/gnu-getopt/bin" ]] && export PATH="/opt/homebrew/opt/gnu-getopt/bin:${PATH}"

{%@@ endif @@%}# Include $(go env GOPATH) to PATH
[[ $(command -v go) ]] && [[ -d "$(go env GOPATH)/bin" ]] && export PATH="$(go env GOPATH)/bin:${PATH}"

{%@@ if wsl == true @@%}
# Connect to windows ssh pageant
# https://github.com/BlackReloaded/wsl2-ssh-pageant
export SSH_AUTH_SOCK={{@@ env['HOME'] @@}}/.ssh/agent.sock
ss -a | grep -q $SSH_AUTH_SOCK
if [ $? -ne 0 ]; then
  rm -f $SSH_AUTH_SOCK
  (setsid nohup socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:{{@@ env['HOME'] @@}}/.ssh/wsl2-ssh-pageant.exe >/dev/null 2>&1 &)
fi

# Currently not used
# Connect to windows gpg agent
# https://github.com/BlackReloaded/wsl2-ssh-pageant
# export GPG_AGENT_SOCK={{@@ env['HOME'] @@}}/.gnupg/S.gpg-agent
# ss -a | grep -q $GPG_AGENT_SOCK
# if [ $? -ne 0 ]; then
#   rm -rf $GPG_AGENT_SOCK
#   (setsid nohup socat UNIX-LISTEN:$GPG_AGENT_SOCK,fork EXEC:"{{@@ env['HOME'] @@}}/.ssh/wsl2-ssh-pageant.exe --gpg S.gpg-agent" >/dev/null 2>&1 &)
# fi

# Set GPG_TTY to enable passphrase entry via tty
export GPG_TTY=$(tty)

# X410 (Windows X11 Server)
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
{%@@ endif @@%}
{%@@ if distro == 'macos' @@%}
export HOMEBREW_CASK_OPTS="--appdir={{@@ env['HOME'] @@}}/Applications"

{%@@ endif @@%}

source {{@@ env['HOME'] @@}}/.commonfunc
{%@@ if vw == true @@%}source {{@@ env['HOME'] @@}}/.vwfunc{%@@ endif @@%}
