dot/bashrc, dot/zshrc: Promote invoking the common config.
[profile] / dot / bashrc
1 ### -*-bash-*-
2 ###
3 ### Bash session things.
4
5 __mdw_shell=bash
6
7 ## Only do this if we haven't done it before. (Note that this guard isn't
8 ## exported, so subshells will need to make their own arrangements.)
9 case ${__mdw_bashrc+t} in
10 t) ;;
11 *) __mdw_bashrc=t
12
13 ###--------------------------------------------------------------------------
14 ### Common shell configuration.
15
16 . "$HOME/.shell-rc"
17
18 ###--------------------------------------------------------------------------
19 ### Other preliminaries.
20
21 ## If we've not run the main profile yet, we should do that first. It sets
22 ## up things we rely on. Also, if there's a system script, we should run
23 ## that too.
24 case ${__mdw_profile+t} in t) ;; *) . "$HOME/.profile" ;; esac
25 __mdw_source_if_exists /etc/bashrc
26
27 ## Completion.
28 __mdw_source_if_exists /etc/bash_completion "$HOME/.bash_completion"
29
30 ###--------------------------------------------------------------------------
31 ### Prompt hacking.
32
33 __mdw_set_prompt_hacks () {
34 case "$TERM" in
35 linux*|screen*|xterm*|putty*|vt100*|eterm*)
36 case "$(tput bold)" in
37 "") bold="\[$(tput md)\]" unbold="\[$(tput me)\]" ;;
38 *) bold="\[$(tput bold)\]" unbold="\[$(tput sgr0)\]" ;;
39 esac
40 gitcolour="\[$(tput setaf 6)\]"
41 rccolour="\[$(tput setaf 1)\]"
42 uncolour="\[$(tput op)\]"
43 nl="\[ \]"
44 ;;
45 esac
46 host='\h' dir=' \w'
47 }
48
49 __mdw_before_cmd_hack () {
50 set -- $(history 1); shift
51 __mdw_preexec "$*"
52 }
53
54 ## Only bother if the shell is interactive.
55 if [ -t 0 ]; then
56 PROMPT_DIRTRIM=5
57 __mdw_source_if_exists /usr/lib/git-core/git-sh-prompt
58 __mdw_set_prompt_pieces
59 PROMPT_COMMAND=__mdw_precmd
60 PS0="\$(__mdw_before_cmd_hack)"
61 fi
62
63 ###--------------------------------------------------------------------------
64 ### Other shell tweaking.
65
66 ## Random shell tweaks.
67 notify=1
68 set -b
69 shopt -u cdable_vars
70 shopt -s cdspell
71 shopt -s checkhash
72 shopt -s checkwinsize
73 shopt -s cmdhist
74 shopt -u dotglob
75 shopt -s expand_aliases
76 shopt -s extglob
77 if (( ${BASH_VERSINFO[0]} >= 4 )); then shopt -s globstar; fi
78 shopt -s gnu_errfmt
79 shopt -s histappend
80 set -o histexpand
81 shopt -s histreedit
82 shopt -u histverify
83 shopt -s hostcomplete
84 shopt -s huponexit
85 shopt -s interactive_comments
86 shopt -s lithist
87 shopt -u mailwarn
88 shopt -u nocaseglob
89 shopt -u nullglob
90 shopt -s promptvars
91 shopt -u shift_verbose
92 shopt -s sourcepath
93 HISTCONTROL=ignorespace:erasedups
94
95 ###--------------------------------------------------------------------------
96 ### Finishing touches.
97
98 ## Run any local hooks.
99 __mdw_source_if_exists "$HOME/.bashrc-local"
100
101 ###----- That's all, folks --------------------------------------------------
102
103 esac