#!/bin/usr/env sh
# Author: Patrick Spek
# License: BSD 3-clause license
#
[ "${DEBUG_DOTFILES}" ] && echo "Setting PATH"
# User-local bin dir
PATH="$HOME/.config/shell/wrappers.d:$PATH"
PATH="$HOME/.local/bin:$PATH"
# snaps were a terrible idea and anyone in favour of them should be ashamed
# of themselves
if [ -d "/snap/bin" ]
then
PATH="$PATH:/snap/bin"
fi
# Raku stuff
if [ -d "$HOME/.raku/bin" ]
then
PATH="$PATH:$HOME/.raku/bin"
fi
if [ -d "/usr/local/share/perl6" ]
then
PATH="$PATH:/usr/local/share/perl6/site/bin"
PATH="$PATH:/usr/local/share/perl6/vendor/bin"
fi
# Python packages
if command -v python >/dev/null 2>&1
then
PATH="$PATH:$(python -c 'import site; print(":".join(map(lambda x: x + "/usr/bin", site.getsitepackages())))')"
PATH="$PATH:$(python -c 'import site; print(":".join(map(lambda x: x + "/usr/sbin", site.getsitepackages())))')"
fi
# Load color definitions if they exist
if [ -f "$HOME/.config/shell/colors/$SHORTSHELL" ]
then
[ "$DEBUG_DOTFILES" ] && printf " Loading color definitions\n"
. "$HOME/.config/shell/colors/$SHORTSHELL"
fi
# Nix package manager
if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]
then
# In case of single-user Nix installation
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
else
if [ -d "/nix/var/nix/profiles/per-user/${USER}" ]
then
# In case of multi-user Nix installation
PATH="${PATH}:/nix/var/nix/profiles/per-user/${USER}/profile/bin"
fi
fi
[ "${DEBUG_DOTFILES}" ] && echo "Setting FPATH"
FPATH="${HOME}/.config/shell/completion ${FPATH}"
[ "${DEBUG_DOTFILES}" ] && echo "Sourcing ~/.config/shell/env"
# shellcheck disable=SC1090
. "${HOME}/.config/shell/env"
if [ -f "${HOME}/.local/etc/shell/env" ]
then
[ "${DEBUG_DOTFILES}" ] && echo "Sourcing ~/.local/etc/shell/env"
# shellcheck disable=SC1090
. "${HOME}/.local/etc/shell/env"
fi
# if ruby is installed and we have a gems folder, include it in the path
if ruby -v > /dev/null 2>&1
then
GEMDIR="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin"
if [ -d "$GEMDIR" ]
then
[ "$DEBUG_DOTFILES" ] && echo " Extending PATH with $GEMDIR"
PATH="$GEMDIR:$PATH"
fi
fi
# Add machine-specific paths from ~/.local/etc/shell/path
if [ -f "$HOME/.local/etc/shell/path" ]
then
for p in $(envsubst < "$HOME/.local/etc/shell/path")
do
PATH="$PATH:$p"
done
fi
# export the extended PATH
export PATH
# Extend MANPATH with user directories
MANPATH="/home/tyil/.local/share/man/:$MANPATH"
# Add aliases
. "$HOME/.config/shell/aliases"
# Add custom functions
[ "${DEBUG_DOTFILES}" ] && echo " Sourcing functions.d"
for f in "$HOME/.config/shell/functions.d"/*
do
[ "${DEBUG_DOTFILES}" ] && echo " $f"
. "$f"
done
# Load profile
if [ -f "${HOME}/.config/shell/profile" ]
then
[ "${DEBUG_DOTFILES}" ] && echo " Loading ~/.config/shell/init"
#shellcheck disable=1090
. "${HOME}/.config/shell/profile"
fi
# show motd
if [ -f "${HOME}/.config/shell/motd" ]; then
[ "${DEBUG_DOTFILES}" ] && echo "Reading motd"
# shellcheck disable=SC1090
. "${HOME}/.config/shell/motd"
fi
# clear terminal
[ "$DEBUG_DOTFILES" ] || clear