Skip to content

Instantly share code, notes, and snippets.

@wirwolf
Last active April 28, 2026 07:00
Show Gist options
  • Select an option

  • Save wirwolf/a44f5394a5e6920064546602c2d4ef74 to your computer and use it in GitHub Desktop.

Select an option

Save wirwolf/a44f5394a5e6920064546602c2d4ef74 to your computer and use it in GitHub Desktop.
BaseConfig
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# ── HISTORY CONTROL ────────────────────────────────────────────────────────────────────
export HISTFILE=~/.bash_history
export HISTSIZE=100000
export HISTFILESIZE=200000
export HISTTIMEFORMAT="%F %T " # optional: timestamp each history entry
export HISTCONTROL=ignoredups # skip consecutive duplicate entries
export HISTIGNORE="ls:ll:cd:pwd:clear:history:exit"
shopt -s histappend # append to the history file, don't overwrite it
PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
# ── shopt ────────────────────────────────────────────────────────────────────
shopt -s autocd # type a directory name to cd into it automatically
shopt -s cdspell # correct minor typos in cd (Documents → Docuents)
shopt -s dirspell # same correction during tab-completion
shopt -s nocaseglob # case-insensitive glob (*.JPG == *.jpg)
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s globstar
# ── readline / bind ──────────────────────────────────────────────────────────────
bind 'set completion-ignore-case on' # case-insensitive Tab
bind 'set show-all-if-ambiguous on' # show completions on first Tab instead of double Tab
bind 'set mark-symlinked-directories on'
# ── env vars ──────────────────────────────────────────────────────────────────────
export EDITOR=nano # default editor
export VISUAL=nano
export LESS='-RFX' # colors, don't clear screen if output fits, skip pager for short output
export MANPAGER='less -R' # colored man pages
export PAGER=less
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# ── PATH ──────────────────────────────────────────────────────────────────────
[[ -d "$HOME/.local/bin" ]] && export PATH="$HOME/.local/bin:$PATH"
[[ -d "$HOME/bin" ]] && export PATH="$HOME/bin:$PATH"
# ── Aliases ──────────────────────────────────────────────────────────────────────
# enable color support of ls and also add handy aliases
if [[ -x /usr/bin/dircolors ]]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [[ -f ~/.bash_aliases ]]; then
. ~/.bash_aliases
fi
# ── Functions ──────────────────────────────────────────────────────────────────────
mkcd() { mkdir -p "$1" && cd "$1"; }
dusort() {
du -sh "${1:-.}"/* 2>/dev/null | sort -rh | head -"${2:-20}"
}
bigfiles() {
local dir="${1:-/volume1}" size="${2:-100M}"
find "$dir" -type f -size +"$size" -exec ls -lh {} \; 2>/dev/null \
| sort -k5 -rh | head -20
}
docker-clean-dangling() {
docker images -f "dangling=true" -q | xargs -r docker rmi
}
# ── PS1 / PROMPT ──────────────────────────────────────────────────────────────────
# set variable identifying the chroot you work in (used in the prompt below)
if [[ -z "${debian_chroot:-}" ]] && [[ -r /etc/debian_chroot ]]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# detect color support
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# git status for PS1
_git_prompt() {
local git_status branch color reset=$'\e[0m' mark
git_status=$(git status --porcelain --branch 2>/dev/null) || return
branch=$(awk 'NR==1{sub(/^## /,""); sub(/\.\.\..*$/,""); print}' <<< "$git_status")
if [[ -n "$(grep -v '^#' <<< "$git_status")" ]]; then
color=$'\e[0;31m'
mark="✗"
else
color=$'\e[0;32m'
mark="✓"
fi
if [[ "$1" == "color" ]]; then
echo -n "$branch ${color}${mark}${reset} "
else
echo -n "$branch ${mark} "
fi
}
git_color_prompt() { _git_prompt color; }
git_prompt() { _git_prompt; }
_build_ps1() {
local ret=$? r=$'\033[0m' grn=$'\033[0;32m' cyn=$'\033[0;36m' red=$'\033[0;31m' yel=$'\033[0;33m'
local chroot="${debian_chroot:+($debian_chroot)}"
local exit_color
[[ $ret -eq 0 ]] && exit_color="$grn" || exit_color="$red"
local _jobs bg_str=''
mapfile -t _jobs < <(jobs -p)
[[ ${#_jobs[@]} -gt 0 ]] && bg_str="bg:${#_jobs[@]} "
local git_str title=''
case "$TERM" in
xterm*|rxvt*) title="\[\e]0;${chroot}\u@\H: \w\a\]" ;;
esac
if [[ "$color_prompt" = yes ]]; then
git_str=$(git_color_prompt)
PS1="${title}${chroot}\[\033[01;32m\]\D{%Y-%m-%d} \t ${bg_str}${git_str}\u@\H\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[${exit_color}\][${ret}]\[${r}\]\n\$ "
else
git_str=$(git_prompt)
PS1="${title}${chroot}\D{%Y-%m-%d} \t ${bg_str}${git_str}\u@\H:\w [${ret}]\n\$ "
fi
}
PROMPT_COMMAND="_build_ps1; $PROMPT_COMMAND"
unset force_color_prompt
# ── Completion ──────────────────────────────────────────────────────────────────
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
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment