diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-04 08:44:50 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-06 16:43:16 +0200 |
| commit | 0bc002288b984d8ec8123c135456570c78a22da3 (patch) | |
| tree | 020ed3f6a7f28a081687a3e46ea190e3aa724f7c /.config/bash | |
| download | dotfiles-0bc002288b984d8ec8123c135456570c78a22da3.tar.gz dotfiles-0bc002288b984d8ec8123c135456570c78a22da3.zip | |
feat: initial setup
- `dotfiles` (this project's CLI)
- foot configuration
- tmux configuration
- bash configuration
- nvim (as a git submodule) + configuration
- ranger configuration
- fzf configuration
- KDE global shortcuts
- Other miscellaneous dependencies
Diffstat (limited to '.config/bash')
| -rw-r--r-- | .config/bash/bashrc | 62 | ||||
| -rw-r--r-- | .config/bash/inputrc | 88 | ||||
| -rw-r--r-- | .config/bash/vi.inputrc | 8 |
3 files changed, 158 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 diff --git a/.config/bash/inputrc b/.config/bash/inputrc new file mode 100644 index 0000000..c56068e --- /dev/null +++ b/.config/bash/inputrc @@ -0,0 +1,88 @@ +# ------------------------------------------------------------------------------ +# Readline configuration file +# ------------------------------------------------------------------------------ +# +# https://www.gnu.org/software/bash/manual/bash.html#Readline-Init-File +# +# Executed by Readline when a program starts the Readline library +# +# Options that take a string parameter cannot have a comment next to them, e.g. +# `set bell-style none # Some comment` will not work. + +# ------------------------------------------------------------------------------ +# Variable settings +# ------------------------------------------------------------------------------ + +# Completion configuration +# +# It's worth noting what's going on here since it's not clear from the +# documentation. +# +# There are three cases to cover for the behavior I want: +# - Only one match → complete +# - Multiple matches → show the list +# - Multiple matches with common prefix → complete prefix and show the list +# +# By default, `menu-complete()` will select the first completion, this covers +# the first case. `show-all-if-ambiguous` covers the second case by showing the +# list when there are multiple choices. `menu-complete-display-prefix` covers +# the third case by completing the common prefix. +set show-all-if-ambiguous on +set menu-complete-display-prefix on + +set editing-mode vi # Vi keybindings +set match-hidden-files off # Don't match hidden files, unless a leading '.' is typed explicitely +set completion-ignore-case on # Ignore case when mathching completions +set search-ignore-case on # Ignore case when searching +set skip-completed-text on # Don't insert match when when completing in the middle of a word +set completion-query-items 100 # Prompt before showing more than this number of completions +set completion-display-width 100 # 100 columns for completion results +set print-completions-horizontally off # Sort completions horizontally +set colored-stats on # Show completions using colors depending on file type +set visible-stats on # Append a character denoting file type +set colored-completion-prefix on # Color the common prefix of completions +set expand-tilde off # Don't expand tilde automatically +set show-mode-in-prompt on # Show current mode (vi-insert, vi-command) in prompt +# String to display for each mode +set vi-cmd-mode-string -CMD- +set vi-ins-mode-string -INS- +# Don't ring the terminal bell +set bell-style none + +# ------------------------------------------------------------------------------ +# Key bindings +# ------------------------------------------------------------------------------ +# +# To unbind: bind to `""` +# +# https://www.gnu.org/software/bash/manual/bash.html#Bindable-Readline-Commands-1 + +$if mode=vi + +# vi-insert ____________________________________________________________________ +set keymap vi-insert +$include ~/.config/bash/vi.inputrc + +"\e\t": shell-expand-line # Alt+Tab perform shell expansion +"\C-i": menu-complete # Tab cycle completions forward +"\e[Z": menu-complete-backward # Shift+Tab cycle completions backward +"\C-a": insert-completions # Ctrl+a insert all completions +"\e!": dynamic-complete-history # Alt+! complete from history entries (not lines!) +"\eh": backward-char # Alt+h one char backward +"\el": forward-char # Alt+l one char forward +"\C-b": beginning-of-line # Ctrl+b beginning of line +"\C-e": end-of-line # Ctrl+e end of line + +$if Bash + +"\ee": "ranger\r" # Alt+e open `ranger` + +$endif + +# vi-command ___________________________________________________________________ +set keymap vi-command +$include ~/.config/bash/vi.inputrc + +"u": vi-undo # u undo + +$endif diff --git a/.config/bash/vi.inputrc b/.config/bash/vi.inputrc new file mode 100644 index 0000000..4ec6049 --- /dev/null +++ b/.config/bash/vi.inputrc @@ -0,0 +1,8 @@ +# Readline key bindings for both the vi-insert and vi-command keymaps + +"\C-l": clear-screen # Ctrl+l clear screen +"\C-w": unix-filename-rubout # Ctrl+w erase word backward (hyphens included) +"\C-k": history-search-backward # Ctrl+k search history backward (non-incremental) +"\C-j": history-search-forward # Ctrl+j search history forward (non-incremental) + +# vim: filetype=readline |
