#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# .bashrc file for ECE 264 Spring 2019
#
# Author:   Alexander J. Quinn -- http://engineering.purdue.edu/~aq
# License:  Public domain (except where noted otherwise below)
#

#------------------------------------------------------------------------------
# In ECE 264 (Spring 2019), we are using an alternative installation of gcc on
# ecegrid.  This gives you gcc v7.1.0, which is quite a bit newer than the
# default, gcc v4.7.  We also use a bash alias to automatically fill in flags
# to gcc that will help you catch bugs.  By default, we turn all of this off
# after the semester, to avoid causing confusion with future classes.
#
# If you want to keep using the newer version of gcc after the Spring 2019
# semester ends, please comment out the line below.  (Add a '#' in front of it.)
#ECE264_SPRING_2019_SETTINGS_EXPIRATION_DATE="20171216"
# You could also change that date to some alternate expiration date.
#------------------------------------------------------------------------------


# Make all files that you create private by default (i.e., not readable,
# writable, or executable by other users on the system).
umask 077

if [[ $- =~ "i" ]]; then  # If this is an interactive session...
    ######################################################################
    # ECE 264
    #

    TODAYS_DATE="$(date +%Y%m%d)"
    if [[ -z "$ECE264_SPRING_2019_SETTINGS_EXPIRATION_DATE"
          || "$ECE264_SPRING_2019_SETTINGS_EXPIRATION_DATE" > "$TODAYS_DATE" ]]; then
        #export PATH="/opt/gcc/7.1.0/bin:$PATH:/home/shay/a/ece264/19sp/bin"
        export PATH="/opt/gcc/7.1.0/bin:/home/shay/a/ece264/19sp/bin:$PATH"
        # Tell bash where to look when you type a command (e.g., '264get', etc.).
        # * /home/shay/a/ece264p0/share/19sp is where we put the ECE 264 scripts.
        # * $PATH is the list of paths that it would check otherwise.
        # * /opt/gcc/7.1.0/bin is where ECN has installed the latest version of gcc.

        alias gcc="gcc -std=c99 -g -Wall -Wshadow --pedantic -Wvla -Werror"
        # Tell bash to automatically add some standard arguments to gcc.  This ensures
        # that everyone in the class is compiling in the same way.
        # * --std=c99 means to use the C99 version of the C language.
        # * -g means to enable gdb by storing information such as your variable names
        #   in the executable
        # * -Wall, -Wshadow, --pedantic, and Wvla turn on extra warnings to let
        #   you know about anomolies in your code might indicate a bug.

        alias valgrind='valgrind --leak-check=full'
        # Tell bash to automatically add the --leak-check=full argument whenever you
        # type 'valgrind'.

        alias 264version_bashrc='echo "You have version 3 of the .bashrc for ECE 26400 Spring 2019.";echo;echo PATH=$PATH;echo;ls -l ~/.bashrc ~/.bash_profile ~/.vimrc'
    fi


    ######################################################################
    # PROMPT FORMAT
    #
    # Make your bash prompt show your current directory in color.
    #
    # Credit:  Cygwin, license: GPL, from the default .bashrc that comes with Cygwin
    export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
    export PS2='> '
    export PS4='+ '
    # To learn more about these codes, see:
    # http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html ...


    ######################################################################
    # ALIASES
    #

    # mcd
    function mcd() {
        # Make a directory and then change to it.  This will be used like an alias.
        mkdir $1
        cd $1
    }

    # less
    alias less='less -r'
    # -r = --raw-control-chars .. means to display raw characters instead of
    # showing ^M, ^R, etc.

    # rm
    alias rm='rm -i'
    # -i = --interactive ... means to prompt before deleting any files, unless
    # -f is added

    # whence
    alias whence='type -a'
    # prints description of a command (i.e., alias, location, etc.) -a means to
    # print all of the places that contain an executable matching the argument

    # ls
    if [ "${BASH_VERSINFO[5]}" == "x86_64-apple-darwin10.0" ]; then
        # Mac version of ls -- useful only if you copy this .bashrc to a Mac.
        alias ls='ls -G -p'
    else
        # GNU version of ls
        alias ls='ls -F --color=tty -B'
    fi

    # ll
    alias ll='ls -l'
    # -l = use long listing format

    # Up arrow to search history
    bind '"\e[A": history-search-backward'
    bind '"\e[B": history-search-forward'
    # Credit: 'user287613' @ http://askubuntu.com/a/475614 - License: CC-BY-SA-3.0
fi

unset ECE264_SPRING_2019_SETTINGS_EXPIRATION_DATE

# vim: set tabstop=4 shiftwidth=4 fileencoding=utf8 expandtab filetype=sh: