summaryrefslogtreecommitdiffstats
path: root/.config/bash/bashrc
diff options
context:
space:
mode:
Diffstat (limited to '.config/bash/bashrc')
-rw-r--r--.config/bash/bashrc62
1 files changed, 62 insertions, 0 deletions
diff --git a/.config/bash/bashrc b/.config/bash/bashrc
new file mode 100644
index 0000000..bd440fc
--- /dev/null
+++ b/.config/bash/bashrc
@@ -0,0 +1,62 @@
+# bashrc
+#
+# Sourced by `~/.bashrc` (which is executed by non-login interactive shells)
+
+[[ $- != *i* ]] && return # if not running interactively, stop
+
+function source_if_readable() {
+ local f="${1:?file argument missing}"
+ # shellcheck disable=1090
+ if [[ -r $f ]]; then source "$f"; fi
+}
+
+# The terminal consumes certain characters before the shell see them. This
+# disables them so Readline can bind them.
+#
+# `stty` settings live on the terminal device, not in the shell process.
+#
+# -ixon Ctrl+S and Ctrl+Q (output flow control)
+# werase undef Ctrl+W (erase word)
+stty -ixon werase undef
+
+# ** expands to all files and directories recursively
+# **/ expands to all directories recursively
+shopt -s globstar
+shopt -s extglob # extended pattern matching (like `?(a|b|c)`)
+
+alias r="fc -s" # See `help fc`
+alias wl-copy="wl-copy --trim-newline"
+
+export INPUTRC="$HOME/.config/bash/inputrc" # Readline configuration
+export VISUAL=nvim EDITOR=nvim # used by various programs like `git`, `fc`, `man`, …
+export MANPAGER="nvim +Man!" MANWIDTH=999 # `nvim` as pager for `man`
+
+# Colors and prompt
+# The terminal emulator sets $TERM
+if [[ $TERM == +(xterm-256color|tmux-256color|foot) ]]; then
+ eval "$(dircolors --bourne-shell)" # Set LS_COLORS which is used by other programs
+ alias ls='ls --color=auto'
+ alias grep='grep --color=auto'
+ alias yay='yay --color auto'
+ alias pacman='pacman --color auto'
+ alias bat='bat --color=always'
+ export LESS="--RAW-CONTROL-CHARS" # `less` display colors instead of the raw escape sequences
+ # Prompt
+ PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W :$SHLVL :\j\[\033[01;32m\]]\$\[\033[00m\] '
+fi
+
+# History
+shopt -s histappend # append to instead of overwriting HISTFILE
+export HISTFILE="$HOME/.config/bash/bash_history" # history file
+export HISTSIZE=1000 # number of commands to save in history
+export HISTTIMEFORMAT='%F %T ' # history entry timesptamp format, also enables multi-line entries
+export HISTFILESIZE=-1 # don't truncate history
+export HISTCONTROL="ignoreboth" # don't save duplicate lines or lines starting with a space
+
+# Completion
+source_if_readable /usr/share/bash-completion/bash_completion # see https://github.com/scop/bash-completion/#bash-completion
+source_if_readable "$HOME/.config/fzf/fzf.bash" # fzf configuration
+
+source_if_readable "$HOME/.config/bash/localrc" # local configuration
+
+# vim: ft=bash