aboutsummaryrefslogblamecommitdiff
path: root/sh/profile
blob: b28892959faf5ad36d951b856e3fab5e5acab404 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                       
                                   
                               
  
 




                                                        
 










                                            
                               



                                  





                                                



                                                                               
  
# Add ~/.local/bin to PATH if it exists
if [ -d "$HOME"/.local/bin ] ; then
    PATH=$HOME/.local/bin:$PATH
fi

# If we can read ~/.oldpwd, make its contents our OLDPWD
if [ -r "$HOME"/.oldpwd ] ; then
    IFS= read -r OLDPWD < "$HOME"/.oldpwd
    export OLDPWD
fi

# Trap on exit to run ~/.logout if it exists
logout_trap() {
    if [ -f "$HOME"/.logout ] ; then
        . "$HOME"/.logout
    fi
    if [ "$1" != EXIT ] ; then
        trap - "$1"
        kill "-$1" "$$"
    fi
}
for sig in EXIT HUP INT TERM ; do
    # shellcheck disable=SC2064
    trap "logout_trap $sig" "$sig"
done
unset -v sig

# Load all supplementary scripts in ~/.profile.d
for sh in "$HOME"/.profile.d/*.sh ; do
    [ -e "$sh" ] && . "$sh"
done
unset -v sh

# If ENV is unset after running those scripts and ~/.shrc exists, set it as ENV
if [ -z "$ENV" ] && [ -f "$HOME"/.shrc ] ; then
    ENV=$HOME/.shrc
    export ENV
fi