# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# history settings
HISTSIZE=5000
HISTFILESIZE=10000

shopt -s histappend

PROMPT_COMMAND="history -a; $PROMPT_COMMAND"

export HISTCONTROL=erasedups

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s globstar

# automatically prepend cd when entering just a path in the shell
shopt -s autocd

# set a fancy prompt (non-color, unless we know we "want" color)
export TERM=xterm-color

# Alias definitions.
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

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

# source misc user scripts
if [ -d ~/git/dotfiles/files ] ; then
	for f in ~/git/dotfiles/files/.*; do if [[ -f $f ]]; then source $f ; fi; done
fi

# source headscale autocompletion script
if [ -f ~/.autoheadscale ] ; then
	. ~/.autoheadscale
fi

# set prompt colors and style
if [ -f ~/.PS1 ] ; then
	source ~/.PS1
else
	PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$ '
fi

# fetch uninstalled package names when attempting command (arch only)
if [ -f /usr/share/doc/pkgfile/command-not-found.bash ] ; then
	source /usr/share/doc/pkgfile/command-not-found.bash
fi