2 # /etc/bash.bashrc: System-wide rc file for interactive bash(1) shells.
3 # Written 2003-2015 by Alexander Barton (alex@barton.de)
6 [ -e ~/.ConfigScripts.debug ] && echo " .. /etc/bash.bashrc ..."
10 [ -z "$PROFILEREAD" -a -r /etc/profile ] && source /etc/profile
11 [ -z "$PROFILEREAD" -a -r ~/.etc/profile ] && source ~/.etc/profile
13 [ -e ~/.ConfigScripts.debug ] && echo " >> /etc/bash.bashrc ..."
21 # Initialize keychain(1) ssh-agent and gpg-agent helper
22 [ -e ~/.ConfigScripts.debug ] && echo " - keychain ..."
23 type -t keychain >/dev/null \
24 && eval "`keychain --agents ssh --eval --inherit any-once --quick --quiet`"
26 # Common command aliases (1/2)
33 set mark-directories on
34 set mark-symlinked-directories on
35 HISTCONTROL=ignoredups
42 # Make sure that the following commands are only run with bash >= 2.x
43 case "$BASH_VERSION" in
44 "0."*|"1."*) return; ;;
49 [ -e ~/.ConfigScripts.debug ] && echo " - shell options ..."
58 ssh -o "StrictHostKeyChecking no" "$@"
61 ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" "$@"
64 # Map up & down to history search once a command has been started
65 bind '"\e[A":history-search-backward'
66 bind '"\e[B":history-search-forward'
69 [ -e ~/.ConfigScripts.debug ] && echo " - colors ..."
71 ansi|cons25|cygwin|dtterm|linux|rxvt|screen*|vt100|vt200|vt220|vt320| \
72 xterm|xterm-color|xterm-256color)
76 # 0: reset / 1: bright / 2: dim / 4: underline / 5: blink /
77 # 7: reverse / 8: hidden.
79 # 30: black / 31: red / 32: green / 33: yellow / 34: blue /
80 # 35: magenta / 36: cyan / 37: white
82 # 40: black / 41: red / 42: green / 43: yellow / 44: blue /
83 # 45: magenta / 46: cyan / 47: white
85 # colors for shell prompt etc.
86 COLOR_RESET="\[\e[0m\]"
87 COLOR_PREPOSTTXT="\[\e[1;37m\]"
88 COLOR_USER="\[\e[0;4m\]"
89 COLOR_AT="\[\e[0;37m\]"
90 COLOR_HOST="\[\e[0;4m\]"
91 COLOR_COLON="\[\e[0;37m\]"
93 COLOR_PROMPT_USER="\[\e[1;32m\]"
94 COLOR_PROMPT_ROOT="\[\e[1;31m\]"
95 COLOR_VCS="\[\e[1;33m\]"
98 # colors for less(1) pager
99 export LESS_TERMCAP_mb=$'\E[1;33m'
100 export LESS_TERMCAP_md=$'\E[1;31m'
101 export LESS_TERMCAP_me=$'\E[0m'
102 export LESS_TERMCAP_se=$'\E[0m'
103 export LESS_TERMCAP_so=$'\E[1;33;44m'
104 export LESS_TERMCAP_ue=$'\E[0m'
105 export LESS_TERMCAP_us=$'\E[1;32m'
108 # Enable bash completion, if available
109 if ! shopt -oq posix; then
110 [ -e ~/.ConfigScripts.debug ] && echo " - bash completion ..."
111 [ -z "$BASH_COMPLETION" -a -r /etc/bash_completion ] \
112 && source /etc/bash_completion
113 [ -z "$BASH_COMPLETION" -a -r /usr/local/etc/bash_completion ] \
114 && source /usr/local/etc/bash_completion
115 [ -z "$BASH_COMPLETION" -a -r /opt/homebrew/etc/bash_completion ] \
116 && source /opt/homebrew/etc/bash_completion
117 [ -z "$BASH_COMPLETION" -a -r /opt/local/etc/bash_completion ] \
118 && source /opt/local/etc/bash_completion
121 # Enable local virtualenvwrapper installation, if available
122 [ -e ~/.ConfigScripts.debug ] && echo " - virtualenvwrapper ..."
123 [ -r /usr/local/bin/virtualenvwrapper.sh ] \
124 && source /usr/local/bin/virtualenvwrapper.sh
127 [ -e ~/.ConfigScripts.debug ] && echo " - prompt ..."
128 PS1="${COLOR_PREPOSTTXT}${PS1_BEGIN:-<}"
129 [ "$LOGNAME" = "root" ] \
130 || PS1="${PS1}${COLOR_USER}\u${COLOR_AT}@"
131 PS1="${PS1}${COLOR_HOST}\h"
132 PS1="${PS1}${COLOR_COLON}:"
133 PS1="${PS1}${COLOR_PATH}\W "
134 PS1="${PS1}${COLOR_HISTORY}\!"
135 PS1="${PS1}${COLOR_PREPOSTTXT}${PS1_END:->}${COLOR_RESET} "
136 [ "$LOGNAME" = "root" ] \
137 && PS1="${PS1}${COLOR_PROMPT_ROOT}\\\$${COLOR_RESET} " \
138 || PS1="${PS1}${COLOR_PROMPT_USER}\\\$${COLOR_RESET} "
139 type -t __git_ps1 >/dev/null \
140 && PS1="\$(__git_ps1 '(${COLOR_VCS}%s${COLOR_RESET}) ')${PS1}"
141 PS1="${chroot_name:+[${COLOR_CHROOT}$chroot_name${COLOR_RESET}] }${PS1}"
142 PS1="${COLOR_RESET}${PS1}"
144 # If the command-not-found package is installed, use it
145 [ -e ~/.ConfigScripts.debug ] && echo " - command_not_found ..."
146 if [ -r /etc/bash_command_not_found ]; then
147 . /etc/bash_command_not_found
148 elif [ -x /usr/lib/command-not-found ]; then
149 function command_not_found_handle {
150 # Check because c-n-f could've been removed in the meantime
151 if [ -x /usr/lib/command-not-found ]; then
152 /usr/bin/python /usr/lib/command-not-found -- $1
160 # Common command aliases (2/2)
161 [ -e ~/.ConfigScripts.debug ] && echo " - aliases ..."
162 alias "lasth"="last | head -n \`expr \\\$LINES - 2\`"
163 alias "lastf"="last | grep -v \"^\$LOGNAME\""
165 # Aliases for screen(1), if installed
166 type -t screen >/dev/null
167 if [ $? -eq 0 ]; then
169 alias "sr"="screen -dr"
170 alias "sx"="screen -x"
173 # less(1) filter, if available
174 type -t lesspipe >/dev/null \
177 # Setup slrn(1) and cleanscore(1), if installed
178 type -t cleanscore >/dev/null \
179 && alias slrn="cleanscore -f ~/.slrnscore && slrn"
181 # Enable color support of ls(1)
182 if [ "$TERM" != "dumb" ]; then
183 type -t dircolors >/dev/null && eval `dircolors -b`
184 ls --color / >/dev/null 2>&1
185 if [ $? -eq 0 ]; then
187 alias ls="ls --color=auto -F"
189 ls -G / >/dev/null 2>&1
190 if [ $? -eq 0 ]; then
197 # If this is an xterm set the title to user@host:dir
198 [ -e ~/.ConfigScripts.debug ] && echo " - prompt command ..."
201 PROMPT_COMMAND='printf "\033]0;${LOGNAME}@${HOSTNAME}: ${PWD}\007"'
207 # Source local files, if readable
208 [ -r "/etc/bashrc.local" ] && source /etc/bashrc.local
209 [ -r "/etc/bash.bashrc.local" ] && source /etc/bash.bashrc.local
210 [ -r "/var/lib/$HOSTNAME/bash.bashrc" ] && source /var/lib/$HOSTNAME/bash.bashrc