#!/usr/bin/env sh

## Source all scripts in ~/.rc.d
if [ -d "$HOME/.rc.d" ]; then
    for f in "$HOME/.rc.d"/*.sh; do
        if [ -r "$f" ]; then
            . "$f"
        fi
    done

    # Source shell-specific scripts if any
    if [ -n "$BASH_VERSION" ]; then
        for f in "$HOME/.rc.d"/*.bash; do
            if [ -r "$f" ]; then
                . "$f"
            fi
        done
    elif [ -n "$ZSH_VERSION" ]; then
        for f in "$HOME/.rc.d"/*.zsh; do
            if [ -r "$f" ]; then
                . "$f"
            fi
        done
    fi
fi

## Autocompletion (Bash)
if [ -n "$BASH_VERSION" ]; then
    if ! shopt -oq posix; then
        if [ -f /usr/share/bash-completion/bash_completion ]; then
            . /usr/share/bash-completion/bash_completion
        elif [ -f /etc/bash_completion ]; then
            . /etc/bash_completion
        fi
    fi
fi

## Paths
# Prepend common personal bin directories to path
if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH"; fi
if [ -d "$HOME/.bin" ] ; then PATH="$HOME/.bin:$PATH"; fi
if [ -d "$HOME/.local/bin" ] ; then PATH="$HOME/.local/bin:$PATH"; fi
if [ -d "$HOME/Applications/bin" ] ; then PATH="$HOME/Applications/bin:$PATH"; fi
export PATH
