# Make sure the shell is interactivecase$- in
*i*);;
*)return;;esac# Don't do anything if restricted, not even sourcing the ENV file# Testing $- for "r" doesn't workifshopt -q restricted_shell >/dev/null 2>&1;thenreturnfi# Clear away all aliases; we do this here rather than in the $ENV file shared# between POSIX shells, because ksh relies on aliases to implement certain# POSIX utilities, like fc(1) and type(1)unalias -a
# If ENV is set, source it to get all the POSIX-compatible interactive stuff;# we should be able to do this even if we're running a truly ancient Bashif[ -n "$ENV"];then
. "$ENV"fi# Ensure we're using at least version 3.0[ -n "$BASH_VERSINFO"]||return# Check version array exists (>=2.0)((BASH_VERSINFO[0] >=3))||return# Check actual major version number# Clear away command_not_found_handle if a system bashrc file set it upunset -f command_not_found_handle
# Keep around 32K lines of history in fileHISTFILESIZE=$((1<< 15))# Ignore duplicate commandsHISTCONTROL=ignoredups# Keep the times of the commands in historyHISTTIMEFORMAT='%F %T '# Use a more compact format for the `time` builtin's outputTIMEFORMAT='real:%lR user:%lU sys:%lS'# Correct small errors in directory names given to the `cd` builtinshopt -s cdspell# Check that hashed commands still exist before running themshopt -s checkhash# Update LINES and COLUMNS after each command if necessaryshopt -s checkwinsize# Put multi-line commands into one history entryshopt -s cmdhist# Include filenames with leading dots in pattern matchingshopt -s dotglob# Enable extended globbing: !(foo), ?(bar|baz)...shopt -s extglob# Append history to $HISTFILE rather than overwriting itshopt -s histappend# If history expansion fails, reload the command to try againshopt -s histreedit# Load history expansion result as the next command, don't run them directlyshopt -s histverify# Don't assume a word with a @ in it is a hostnameshopt -u hostcomplete# Don't change newlines to semicolons in historyshopt -s lithist# Don't try to tell me when my mail is readshopt -u mailwarn# Don't complete a Tab press on an empty line with every possible commandshopt -s no_empty_cmd_completion# Use programmable completion, if availableshopt -s progcomp# Warn me if I try to shift nonexistent values off an arrayshopt -s shift_verbose# Don't search $PATH to find files for the `source` builtinshopt -u sourcepath# These options only exist since Bash 4.0-alphaif ((BASH_VERSINFO[0] >= 4)) ; then # Correct small errors in directory names during completion shopt -s dirspell # Allow double-star globs to match files and recursive paths shopt -s globstar # Warn me about stopped jobs when exiting # Available since 4.0, but only set it if >=4.1 due to bug:
# <https://lists.gnu.org/archive/html/bug-bash/2009-02/msg00176.html>if((BASH_VERSINFO[1] >=1));thenshopt -s checkjobs
fi# Expand variables in directory completion# Only available since 4.3if((BASH_VERSINFO[1] >=3));thenshopt -s direxpand
fifi# Load Bash-specific startup filesfor sh in "$HOME"/.bashrc.d/*.bash ;do[[ -e $sh]]||continuesource"$sh"doneunset -v sh