# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.

# if running with bash
if [ -n "$BASH_VERSION" ]; then
  # include .bashrc if it exists
  if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
  fi
else
  # Expanding PATH with users bin
  if [ -d "$HOME/.local/bin" ] ; then
    export PATH="$HOME/.local/bin:$PATH"
  fi
  
  # Check if XDG environment variables are set or set them to default
  if [ -z "$XDG_DATA_HOME" ]; then
    export XDG_DATA_HOME=$HOME/.local/share
  fi
  if [ -z "$XDG_CONFIG_HOME" ]; then
    export XDG_CONFIG_HOME=$HOME/.config
  fi
  if [ -z "$XDG_STATE_HOME" ]; then
    export XDG_STATE_HOME=$HOME/.local/state
  fi
  if [ -z "$XDG_CACHE_HOME" ]; then
    export XDG_CACHE_HOME=$HOME/.cache
  fi
  
  # ==============================
  # Languages
  # ==============================
  
  # Cargo env config
  if [ -d "$HOME/.cargo/bin" ]; then
    export PATH="$HOME/.cargo/bin:$PATH"
  fi
  
  # Nim env config
  if [ -d "$HOME/.nimble/bin" ]; then
    export PATH="$HOME/.nimble/bin:$PATH"
  fi
  
  # Go env config
  if [ -d "$HOME/go/bin" ]; then
    export PATH="$HOME/go/bin:$PATH"
  fi
  
  # Deno env config
  if [ -f "$HOME/.deno/bin/deno" ]; then
    export DENO_INSTALL="$HOME/.deno"
    export PATH="$DENO_INSTALL/bin:$PATH"
  fi
  
  # opt-out for .NET telemetry
  if command -v dontnet 1> /dev/null; then
    export DOTNET_CLI_TELEMETRY_OPTOUT=1
  fi
fi