1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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
|