summaryrefslogtreecommitdiff
path: root/dotfiles/system/.bashrc
diff options
context:
space:
mode:
Diffstat (limited to 'dotfiles/system/.bashrc')
-rw-r--r--dotfiles/system/.bashrc99
1 files changed, 58 insertions, 41 deletions
diff --git a/dotfiles/system/.bashrc b/dotfiles/system/.bashrc
index b5290cd..b2177d9 100644
--- a/dotfiles/system/.bashrc
+++ b/dotfiles/system/.bashrc
@@ -1,59 +1,76 @@
#!/bin/bash
-# cjennings .bashrc
-
-# tells shellcheck not to follow references to other files
-# shellcheck source=/dev/null
+# .bashrc
+# Craig Jennings <c@cjennings.net>
+#
+# Bash-specific interactive shell settings.
+# Aliases, functions, prompt, completions, shell options.
# If not running interactively, don't do anything
case $- in
- *i*) ;;
- *) return;;
+ *i*) ;;
+ *) return;;
esac
-# env variables, aliases, and functions that are not bash specific
-source "$HOME"/.profile
-
-# don't put duplicate lines or lines starting with space in the history.
-HISTCONTROL=ignoreboth
-
-# infinite history
-HISTSIZE=HISTFILESIZE=
-
-# append and reload the history after each command
-PROMPT_COMMAND="history -a; history -n"
+# =============================================================================
+# Environment Variables (from .profile)
+# =============================================================================
+# Source .profile for env vars (needed for non-login interactive shells)
+[ -f "$HOME/.profile" ] && . "$HOME/.profile"
-# ignore the following commands from the history
-HISTIGNORE="ls:ll:cd:pwd:bg:fg:history"
+# =============================================================================
+# Shell Options
+# =============================================================================
+shopt -s histappend # append to history file, don't overwrite
+shopt -s checkwinsize # update LINES and COLUMNS after each command
+shopt -s autocd # cd to directory by typing its name
+shopt -s cdspell # correct minor spelling errors in cd
+shopt -s dirspell # correct spelling errors during tab-completion
-# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+# =============================================================================
+# History
+# =============================================================================
+HISTCONTROL=ignoreboth # ignore duplicates and lines starting with space
HISTSIZE=100000
HISTFILESIZE=10000000
+HISTIGNORE="ls:ll:cd:pwd:bg:fg:history:exit"
+PROMPT_COMMAND="history -a; history -n" # append and reload after each command
-# append to the history file, don't overwrite it
-shopt -s histappend
+# =============================================================================
+# Prompt
+# =============================================================================
+PS1='[\d, \t] \u@\H:\w \n$ '
-# cd to directory by typing its name
-shopt -s autocd
-
-# check window size after each command + update LINES and COLUMNS values.
-shopt -s checkwinsize
-
-# enable programmable completion features
+# =============================================================================
+# Completions
+# =============================================================================
if ! shopt -oq posix; then
- if [ -f /usr/share/bash-completion/bash_completion ]; then
- . /usr/share/bash-completion/bash_completion
- elif [ -f /etc/bash_completion ]; then
- . /etc/bash_completion
- fi
+ if [ -f /usr/share/bash-completion/bash_completion ]; then
+ . /usr/share/bash-completion/bash_completion
+ elif [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+ fi
fi
-if [ -f /etc/bash_completion ]; then
- . /etc/bash_completion
+
+# =============================================================================
+# Source modular bash configs from .bashrc.d/
+# =============================================================================
+if [ -d "$HOME/.bashrc.d" ]; then
+ for file in "$HOME/.bashrc.d"/*.sh; do
+ [ -r "$file" ] && . "$file"
+ done
+ unset file
fi
-export PS1="[\d, \t] \u@\H:\w \n$ "
+# =============================================================================
+# Tool-specific initialization
+# =============================================================================
+# FZF
+[ -f "$HOME/.fzf.bash" ] && . "$HOME/.fzf.bash"
-source "$HOME"/.profile
+# Deno
+[ -f "$HOME/.deno/env" ] && . "$HOME/.deno/env"
+[ -f "$HOME/.local/share/bash-completion/completions/deno.bash" ] && \
+ . "$HOME/.local/share/bash-completion/completions/deno.bash"
-[ -f "$HOME"/.fzf.bash ] && source "$HOME"/.fzf.bash
-. "/home/cjennings/.deno/env"
-source /home/cjennings/.local/share/bash-completion/completions/deno.bash \ No newline at end of file
+# Zoxide (smart cd)
+command -v zoxide >/dev/null 2>&1 && eval "$(zoxide init bash)"