#{- ~/.profile -}#

# Only execute this file once per shell
if [ -n "$__PROFILE_SOURCED" ]; then return; fi
export __PROFILE_SOURCED=1

#{- PATH -}#

# Prepend ~/.local/bin to the path and append the current directory to the path
export PATH="$HOME/.local/bin:$PATH:."

# Add a local terminfo cache for dealing with shenanigans
export TERMINFO_DIRS="$HOME/.local/share/terminfo:$TERMINFO_DIRS"

#{- ENVIRONMENT VARIABLES -}#

# Export language and sorting preferences.
export LANG="en_US.UTF-8"
export LC_COLLATE="C"

# Export editor preferences.
if which nvim &> /dev/null; then
  export PREFERRED_VIM=nvim
else
  export PREFERRED_VIM=vim
fi
export EDITOR="$PREFERRED_VIM"
export VISUAL="$PREFERRED_VIM"

# Export browser preferences.
export BROWSER="firefox"

# Export pager preferences.
export PAGER="less"
export LESSHISTFILE="-"

# Export python preferences.
export PYTHONSTARTUP="$HOME/.pythonrc"

# History preferences
if [ ! -w "$HOME/.history/sh" ]; then
	if [ ! -d "$HOME/.history" ]; then
		mkdir "$HOME/.history"
	fi
	touch "$HOME/.history/sh"
fi
export HISTSIZE=5000
export HISTFILE="$HOME/.history/sh"
export HISTFILESIZE=10000

if [ -r "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
	. "$HOME/.nix-profile/etc/profile.d/nix.sh"
elif [ -r "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh" ]; then
	. "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh"
fi
