# If not running interactively, don't do anything
case $- in
  *i*) ;;
    *) return ;;
esac

# ── Identity ───────────────────────────────────────────
DEFAULT_USER="$USER"

# ── Editor ─────────────────────────────────────────────
export EDITOR='nvim'

# ── PATH additions ─────────────────────────────────────
export GOPATH="$HOME/go"
export PATH="$PATH:$GOPATH/bin:/usr/local/go/bin"
export PATH="$PATH:$HOME/.local/bin"
export PATH="$PATH:$HOME/.pulumi/bin"
export CPLUS_INCLUDE_PATH=/usr/local/include

# ── NVM ────────────────────────────────────────────────
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"

# ── Rust/Cargo ─────────────────────────────────────────
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"

# ── SSH agent ──────────────────────────────────────────
if [ -z "$SSH_AGENT_PID" ] || ! kill -0 "$SSH_AGENT_PID" 2>/dev/null; then
  eval "$(ssh-agent -s)"
  ssh-add 2>/dev/null
fi

# ── Secrets (keep this file chmod 600) ─────────────────
[ -f "$HOME/.secrets" ] && . "$HOME/.secrets"

# ── FZF ────────────────────────────────────────────────
[ -f ~/.fzf.bash ] && . ~/.fzf.bash

# ── Git completion ─────────────────────────────────────
[ -f /usr/share/bash-completion/completions/git ] \
  && . /usr/share/bash-completion/completions/git

# ── Oh My Posh ─────────────────────────────────────────
eval "$(oh-my-posh init bash --config ~/.config/oh-my-posh/theme.omp.json)"

# ── Aliases ────────────────────────────────────────────
[ -f "$HOME/dotfiles/aliases.bash" ] && . "$HOME/dotfiles/aliases.bash"

# ── work() helper ──────────────────────────────────────
work() {
  set +e
  local proj="$HOME/Drives/500GB/PycharmProjects/time_logix"
  cd "$proj" || { echo "No such dir: $proj" >&2; return 1; }
  [ -d venv ] || python3 -m venv venv || { echo "venv create failed" >&2; return 1; }
  . venv/bin/activate
  trap 'deactivate 2>/dev/null || true' RETURN
  python main.py
  local code=$?
  cd ~ || true
  [ $code -ne 0 ] && echo "main.py exited with code $code"
}
