summaryrefslogtreecommitdiff
path: root/config/bashrc
diff options
context:
space:
mode:
Diffstat (limited to 'config/bashrc')
-rw-r--r--config/bashrc95
1 files changed, 95 insertions, 0 deletions
diff --git a/config/bashrc b/config/bashrc
new file mode 100644
index 0000000..2159098
--- /dev/null
+++ b/config/bashrc
@@ -0,0 +1,95 @@
+# shellcheck shell=bash
+# ~/.bashrc — bash's interactive entry point, the counterpart of config/zshrc.
+#
+# Layering (see config/env's header for the full picture):
+# config/env environment, every shell, every mode
+# config/profile shared interactive layer (aliases, history, theme, profile.d)
+# config/bashrc bash-specific interactive bits <- this file
+# config/zshrc zsh-specific interactive bits
+#
+# bash and zsh disagree about which file a *login interactive* shell reads:
+# zsh reads ~/.zprofile AND ~/.zshrc, but bash reads only ~/.profile and never
+# ~/.bashrc. So the two entry points source each other, guarded both ways:
+# - entered here (interactive non-login) -> we source ~/.profile below
+# - entered via ~/.profile (login) -> it sources ~/.bashrc at its end
+# The __dotfiles_* flags below make sure exactly one direction fires.
+
+# Non-interactive bash never needs any of this, and a login *non*-interactive
+# shell can reach here via ~/.profile. Bail out before doing any work.
+case $- in
+ *i*) ;;
+ *) return ;;
+esac
+
+__dotfiles_bashrc=1
+
+# The shared interactive layer, unless ~/.profile is what sourced us.
+if [ -z "${__dotfiles_profile:-}" ] && [ -r "$HOME/.profile" ]; then
+ # shellcheck source=/dev/null
+ . "$HOME/.profile"
+fi
+
+# --------------------------------------------------------------------- history
+# config/profile sets HISTFILE and HISTSIZE for both shells. These are the bash
+# spellings of the zsh options set alongside them in config/profile.
+HISTFILESIZE="$HISTSIZE"
+HISTCONTROL=ignoreboth # HIST_IGNORE_DUPS + HIST_IGNORE_SPACE
+shopt -s histappend # INC_APPEND_HISTORY
+
+# ---------------------------------------------------------------------- shopts
+shopt -s checkwinsize # keep $LINES/$COLUMNS right after a resize
+shopt -s globstar 2>/dev/null # ** recurses, as in zsh
+
+# ---------------------------------------------------------------------- colours
+# config/profile already aliases ls to lsd when it is installed; only fall back
+# to coreutils colouring when it isn't, so the two can't fight over the alias.
+if [ -x /usr/bin/dircolors ]; then
+ if [ -r "$HOME/.dircolors" ]; then
+ eval "$(dircolors -b "$HOME/.dircolors")"
+ else
+ eval "$(dircolors -b)"
+ fi
+ command -v lsd >/dev/null 2>&1 || alias ls='ls --color=auto'
+ alias grep='grep --color=auto'
+ alias fgrep='fgrep --color=auto'
+ alias egrep='egrep --color=auto'
+fi
+
+alias ll='ls -alF'
+alias la='ls -A'
+alias l='ls -CF'
+
+# ------------------------------------------------------------------- lesspipe
+# Debian/Ubuntu's pager preprocessor. config/profile sets LESS/PAGER.
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# --------------------------------------------------------------------- prompt
+# Mirrors the zsh fallback prompt in config/zshrc: dim basename, then ∴
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
+ debian_chroot=$(cat /etc/debian_chroot)
+fi
+PS1='${debian_chroot:+($debian_chroot)}\[\e[38;5;244m\]\W\[\e[0m\] ∴ '
+
+# ---------------------------------------------------------------- completion
+# bash-completion 2.x needs bash >= 4.2, but macOS still ships bash 3.2 as
+# /bin/bash. Without the version guard, sourcing Homebrew's copy under 3.2
+# spews "complete: nosort: invalid option name" on every prompt.
+if ! shopt -oq posix && [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
+ if [ -r /usr/share/bash-completion/bash_completion ]; then
+ # shellcheck source=/dev/null
+ . /usr/share/bash-completion/bash_completion
+ elif [ -r /etc/bash_completion ]; then
+ # shellcheck source=/dev/null
+ . /etc/bash_completion
+ elif [ -r /opt/homebrew/etc/profile.d/bash_completion.sh ]; then
+ # shellcheck source=/dev/null
+ . /opt/homebrew/etc/profile.d/bash_completion.sh
+ fi
+fi
+
+# Host-local interactive bash setup. Kept for parity with the stock Ubuntu
+# ~/.bashrc this file replaces; ~/.localprofile covers both shells.
+# shellcheck source=/dev/null
+[ -r "$HOME/.bash_aliases" ] && . "$HOME/.bash_aliases"
+
+# vim: filetype=sh