#!/bin/sh
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# XDG Base Dirs
XDG_DATA_HOME="$HOME/.local/share"
XDG_CONFIG_HOME="$HOME/.config"
XDG_STATE_HOME="$HOME/.local/state"
XDG_CACHE_HOME="$HOME/.cache"

# [[ "$TERM_PROGRAM" = "vscode" ]] && . "$(code --locate-shell-integration-path $0)"

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ]; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ]; then
    PATH="$HOME/.local/bin:$PATH"
fi

# Source Cargo Environment
if [[ -f "$HOME/.cargo/env" ]]; then
    . "$HOME/.cargo/env"
elif [[ -f ~/.local/share/cargo/env ]]; then
    source  ~/.local/share/cargo/env 
fi
# Source Nix Environment
if [ -e "$HOME"/.nix-profile/etc/profile.d/nix.sh ]; then
    . "$HOME"/.nix-profile/etc/profile.d/nix.sh
    # else
    #     echo "If this doesn't work, comment out this part of .zshenv"
    #     sh <(curl -L https://nixos.org/nix/install) --no-daemon;
fi

# Add Ruby
#[ "${PATH#*"$HOME"/.local/share/gem/ruby/*/bin:}" = "$PATH" ] && export PATH="$HOME/.local/share/gem/ruby/*/bin:$PATH"

# User bin folder
[ "${PATH#*"$HOME"/.local/bin:}" = "$PATH" ] && export PATH="$HOME/.local/bin:$PATH"

# add nodejs
# [ "${PATH#*"$HOME"/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:}" = "$PATH" ] && export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"

# add go
[ "${PATH#*"$HOME"/go/bin:}" = "$PATH" ] && export PATH="$HOME/go/bin:$PATH"

# Set PATH, MANPATH, etc., for Homebrew.
[ -e /home/linuxbrew/.linuxbrew/bin/brew ] && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)

# pnpm
export PNPM_HOME="$XDG_DATA_HOME/pnpm"
[ "${PATH#*$PNPM_HOME:}" = "$PATH" ] && export PATH="$PNPM_HOME:$PATH"

# npm
export NPM_CONFIG_PREFIX="$XDG_DATA_HOME/npm-global"
[ "${PATH#*$NPM_CONFIG_PREFIX/bin:}" = "$PATH" ] && export PATH="$NPM_CONFIG_PREFIX/bin:$PATH"

# Make Cargo install to user bin directory
export CARGO_HOME="$XDG_DATA_HOME/cargo"
export CARGO_INSTALL_ROOT="$HOME/.local"

export GNUPGHOME="$XDG_DATA_HOME/gnupg"

# If you use non-default GnuPG Home directory, you will need to edit all
# socket files to use the values of gpgconf --list-dirs.
# If you set your SSH_AUTH_SOCK manually, keep in mind that your socket
# location may be different if you are using a custom GNUPGHOME

export LESSHISTFILE="$XDG_STATE_HOME/less/history"

export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc"
