#!/usr/bin/env bash

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

# derived from Ubuntu's default .bashrc


# If not running interactively, don't do anything
case $- in
  *i*) ;;
  *) return;;
esac

# Don't put duplicate linesin the history.
# Don't store commands that start with an empty space.
# See bash(1) for more options
HISTCONTROL=ignoreboth

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

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000000
HISTFILESIZE=2000000

# 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

# If set, the pattern "*" will also match dotfiles.
shopt -s dotglob

stty -ixon


# Taken from:
# https://sanctum.geek.nz/arabesque/better-bash-history/

# Record timestamps
# If you set $HISTTIMEFORMAT to something useful, Bash will record the timestamp of each command in its history. In this variable you can specify the format in which you want this timestamp displayed when viewed with history. I find the full date and time to be useful, because it can be sorted easily and works well with tools like cut and awk.
HISTTIMEFORMAT='%F %T '

# Use one command per line
# To make your .bash_history file a little easier to parse, you can force commands that you entered on more than one line to be adjusted to fit on only one with the cmdhist option:
shopt -s cmdhist

# Store history immediately
# By default, Bash only records a session to the .bash_history file on disk when the session terminates. This means that if you crash or your session terminates improperly, you lose the history up to that point. You can fix this by recording each line of history as you issue it, through the $PROMPT_COMMAND variable:
PROMPT_COMMAND='history -a'
