# ~/.bashrc: executed by bash(1) for non-login shells.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history.
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# set big history
export HISTSIZE=100000
export HISTFILESIZE=$HISTSIZE

# append to history after each command finishes
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"

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

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set fancy prompt
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # color supported
    #PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[32m\]╭─ \u@\h \w ─╼\n╰╼ \$\[\033[00m\] "
    PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[32m\]\u@\h \w\n\$\[\033[00m\] "
else
    # no color
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

# set xterm title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of various utilities
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# ever seen a monochrome xterm?  I sure haven't
if [ "$TERM" = "xterm" ]; then
    export TERM=xterm-256color
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

# aliases
alias svn='colorsvn'

# environment
export LC_MEASUREMENT="en_CA.UTF-8"
export LC_MONETARY="en_CA.UTF-8"
export LC_NUMERIC="en_CA.UTF-8"
export LC_PAPER="en_CA.UTF-8"
export LC_TIME="en_DK.UTF-8"
export WINDOW_MANAGER="/usr/bin/awesome"
export CFLAGS="-O2 -march=native -fomit-frame-pointer -DNDEBUG -ftree-vectorize"
export CXXFLAGS="$CFLAGS"
export GTK_IM_MODULE="xim"
export EDITOR="emacsclient"
export CXX=/usr/lib/ccache/g++-6
export CC=/usr/lib/ccache/gcc-6

# colorize man
man() {
	env \
		LESS_TERMCAP_mb=$(printf "\e[31m") \
		LESS_TERMCAP_md=$(printf "\e[1;32m") \
		LESS_TERMCAP_me=$(printf "\e[0m") \
		LESS_TERMCAP_se=$(printf "\e[0m") \
		LESS_TERMCAP_so=$(printf "\e[36m") \
		LESS_TERMCAP_ue=$(printf "\e[0m") \
		LESS_TERMCAP_us=$(printf "\e[33m") \
			man "$@"
}

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