#!/hint/bash # ~/.bashrc: Sourced by bash(1) for interactive non-login shells # # I include this file for all interactive invocations of bash(1), whether # they are login shells or not. # If not running interactively, don't do anything [[ $- != *i* ]] && return # GDM failsafe ignores profile (login) settings, but I use XDG stuff # here. . "${XDG_CONFIG_HOME:-$HOME/.config}"/login.d/??_xdg.sh # Why is this not on by default? # "We have a cached value, but it isn't valid anymore. Should we trash it?" # "Duh, yes!" shopt -s checkhash ################################################################################ # History settings # don't overwrite GNU Midnight Commander's setting of `ignorespace'. HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups HISTFILE=${XDG_CACHE_HOME}/bash/history HISTTIMEFORMAT='[%Y-%m-%d %H:%M] ' HISTSIZE=5000 shopt -s histappend # append to the history file, don't overwrite it mkdir -p "${HISTFILE%/*}" # General settings shopt -s checkwinsize # update the values of LINES and COLUMNS shopt -s globstar # Let ** recursively scan directories ################################################################################ # Overly complicated setting of PS1 # ################################################################################ # Belongs in aliases, but I use it here term-title() { local fmt='' case "$TERM" in screen|tmux) fmt='\ek%s\e\\';; xterm*|rxvt*) fmt='\e]0;%s\a';; esac printf "$fmt" "$*" } PROMPT_COMMAND='' make_prompt() { echo "${BOLD}${GREEN}\u@\h${BLUE}:\w${RESET}" } if tput setaf 1 &>/dev/null; then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) RESET="$(tput sgr0)" BOLD="$(tput bold)" RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" BLUE="$(tput setaf 4)" _STATUS="${BOLD}[" _STATUS+="\$(v=\$?; [[ \$v = 0 ]] && c='${GREEN}' || c='${RED}'; printf %s%03i \$c \$v)" _STATUS+="${RESET}${BOLD}]${RESET}" else _STATUS='[$(printf "%03i" $?)]' fi PS1="${_STATUS} $(make_prompt)"'\n\$ ' unset RESET BOLD RED GREEN BLUE _STATUS PS1="$(term-title $(make_prompt))$PS1" unset make_prompt ################################################################################ # Include modular config files if [[ -d ${XDG_CONFIG_HOME}/bash/rc.d ]]; then for file in "${XDG_CONFIG_HOME}/bash/rc.d"/*.sh; do . "$file" done fi