#!/bin/sh

echo "[INFO] Running: zsh-set-env.sh"

XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"

{{ if .wheel }}

echo "[INFO] Setting global zshenv that sets ZDOTDIR if available"
echo "[ACTION] Elevation required. "

if [ -f /etc/zshenv ]; then
    sudo cp "$CHEZMOI_SOURCE_DIR/dot_config/zsh/global.zshenv" /etc/zshenv
fi

if [ -f /etc/zsh/zshenv ]; then
    sudo cp "$CHEZMOI_SOURCE_DIR/dot_config/zsh/global.zshenv" /etc/zsh/zshenv
fi

{{ else }}

cp "$CHEZMOI_SOURCE_DIR/dot_config/zsh/global.zshenv" "$HOME/.zshenv"

{{ end }}

mkdir -p $XDG_STATE_HOME/zsh
