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