dotfiles/.bashrc

87 lines
2.2 KiB
Bash
Raw Normal View History

2018-11-01 01:04:07 +01:00
#
# ~/.bashrc -- Sourced by bash in interactive non-login shells; includes ~/bashrc.d/* and ~/.bashrc.local
2018-11-01 01:04:07 +01:00
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Bash settings
set -o noclobber
shopt -s checkwinsize
shopt -s histappend
2019-03-01 15:34:22 +01:00
export HISTCONTROL=ignoreboth
export HISTSIZE=20000
export HISTFILESIZE=20000
export PROMPT_DIRTRIM=3
2018-11-01 01:04:07 +01:00
2023-11-22 16:39:37 +01:00
# Save and display timestamps for history
HISTTIMEFORMAT="[%F %T] "
# Color output and default options
2018-11-01 01:04:07 +01:00
export GREP_OPTS='--color=auto'
export LS_OPTS='--color=auto -hFN --group-directories-first'
export LESS="-Ri"
2018-11-01 01:04:07 +01:00
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# Set default options
2018-11-01 01:04:07 +01:00
alias ls='ls ${LS_OPTS}'
alias grep='grep ${GREP_OPTS}'
2019-04-30 20:10:54 +02:00
alias diff='diff --color=auto'
alias ip='ip -color=auto'
2018-11-01 01:04:07 +01:00
# Common shortcut aliases
2018-11-01 01:04:07 +01:00
alias l='ls -l'
alias la='ls -a'
alias ll='ls -la'
# Colored man pages
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
2019-01-12 14:16:29 +01:00
}
# (Other aliases are defined in .bashrc.d/10_common_aliases.sh etc.)
2020-02-25 02:50:19 +01:00
2019-08-15 15:50:42 +02:00
# Load z
[[ -r "/usr/share/z/z.sh" ]] && source /usr/share/z/z.sh
# Define colors for bash prompt (will also be used in .bashrc.local)
TRED='\[\e[0;31m\]' # Red
TGREEN='\[\e[0;32m\]' # Green
TBLUE='\[\e[0;34m\]' # Blue
TGREENB='\[\e[1;32m\]' # Green bold
TCYANB='\[\e[1;36m\]' # Cyan bold
TWHITEB='\[\e[1;37m\]' # White bold
TRESET='\[\e[0m\]' # Text Reset
# Set default prompt
2018-11-01 01:04:07 +01:00
if [[ ${EUID} == 0 ]] ; then
PS1="${TRED}\u@\h ${TBLUE}\w ${TWHITEB}\$ ${TRESET}"
else
PS1="${TGREEN}\u@\h ${TBLUE}\w ${TWHITEB}\$ ${TRESET}"
fi
# Include drop-in files
2025-12-05 03:36:38 +01:00
if [[ -d ~/.config/bashrc.d ]]; then
for f in ~/.config/bashrc.d/*; do
[[ -f $f ]] && source "$f"
done
fi
2025-12-05 03:36:38 +01:00
# Deprecation warning for old drop-in file locations
if [[ -e ~/.bashrc.d || -e ~/.bashrc.local ]]; then
echo "WARNING: ~/.bashrc.d and ~/.bashrc.local are ignored, please use ~/.config/bashrc.d/ instead."
fi
2018-11-01 01:04:07 +01:00
# Clean up environment variables
unset TRED TGREEN TBLUE TGREENB TCYANB TWHITEB TRESET