Commit | Line | Data |
---|---|---|
ca7933c9 | 1 | ### -*-bash-*- |
59c9c0e4 | 2 | ### |
74a53e28 MW |
3 | ### Bash session things. |
4 | ||
5 | __mdw_shell=bash | |
f617db13 | 6 | |
59c9c0e4 MW |
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.) | |
e849519a | 9 | case ${__mdw_bashrc+t} in |
74a53e28 | 10 | t) ;; |
e849519a | 11 | *) __mdw_bashrc=t |
74a53e28 | 12 | |
4877b8d8 MW |
13 | ###-------------------------------------------------------------------------- |
14 | ### Hook implementation. | |
15 | ||
16 | __mdw_precmd_hook= __mdw_preexec_hook= | |
17 | __mdw_running=t | |
18 | ||
19 | __mdw_run_precmd_hook () { | |
4877b8d8 | 20 | __mdw_runhook __mdw_precmd_hook "$@" |
885b29ac | 21 | __mdw_running=nil |
4877b8d8 MW |
22 | } |
23 | __mdw_run_preexec_hook () { | |
24 | case $__mdw_running in | |
25 | t) ;; | |
26 | nil) | |
27 | __mdw_running=t; | |
28 | set -- $(history 1); shift | |
29 | __mdw_runhook __mdw_preexec_hook "$*" | |
30 | ;; | |
31 | esac | |
32 | } | |
33 | ||
34 | PROMPT_COMMAND=__mdw_run_precmd_hook | |
35 | trap __mdw_run_preexec_hook DEBUG | |
36 | ||
3b41df91 MW |
37 | ###-------------------------------------------------------------------------- |
38 | ### Common shell configuration. | |
39 | ||
74a53e28 | 40 | . "$HOME/.shell-rc" |
f617db13 | 41 | |
3b41df91 MW |
42 | ###-------------------------------------------------------------------------- |
43 | ### Other preliminaries. | |
44 | ||
59c9c0e4 MW |
45 | ## If we've not run the main profile yet, we should do that first. It sets |
46 | ## up things we rely on. Also, if there's a system script, we should run | |
47 | ## that too. | |
74a53e28 MW |
48 | case ${__mdw_profile+t} in t) ;; *) . "$HOME/.profile" ;; esac |
49 | __mdw_source_if_exists /etc/bashrc | |
f617db13 | 50 | |
5e662c38 | 51 | ## Completion. |
74a53e28 | 52 | __mdw_source_if_exists /etc/bash_completion "$HOME/.bash_completion" |
5e662c38 | 53 | |
59c9c0e4 MW |
54 | ###-------------------------------------------------------------------------- |
55 | ### Prompt hacking. | |
f617db13 | 56 | |
74a53e28 | 57 | __mdw_set_prompt_hacks () { |
15b95c26 | 58 | case "$TERM" in |
8a075bd7 | 59 | linux*|screen*|xterm*|putty*|vt100*|eterm*) |
59c3438f MW |
60 | case "$(tput bold)" in |
61 | "") bold="\[$(tput md)\]" unbold="\[$(tput me)\]" ;; | |
62 | *) bold="\[$(tput bold)\]" unbold="\[$(tput sgr0)\]" ;; | |
63 | esac | |
1273afa0 | 64 | gitcolour="\[$(tput setaf 6)\]" |
f00ae4fa MW |
65 | rccolour="\[$(tput setaf 1)\]" |
66 | uncolour="\[$(tput op)\]" | |
9bd5ab69 | 67 | nl="\[\r\]" |
59c3438f | 68 | ;; |
15b95c26 | 69 | esac |
74a53e28 MW |
70 | host='\h' dir=' \w' |
71 | } | |
15b95c26 | 72 | |
74a53e28 MW |
73 | ## Only bother if the shell is interactive. |
74 | if [ -t 0 ]; then | |
75 | PROMPT_DIRTRIM=5 | |
76 | __mdw_source_if_exists /usr/lib/git-core/git-sh-prompt | |
77 | __mdw_set_prompt_pieces | |
59c9c0e4 | 78 | fi |
15b95c26 | 79 | |
59c9c0e4 MW |
80 | ###-------------------------------------------------------------------------- |
81 | ### Other shell tweaking. | |
f617db13 | 82 | |
59c9c0e4 | 83 | ## Random shell tweaks. |
f617db13 MW |
84 | notify=1 |
85 | set -b | |
86 | shopt -u cdable_vars | |
87 | shopt -s cdspell | |
88 | shopt -s checkhash | |
89 | shopt -s checkwinsize | |
90 | shopt -s cmdhist | |
91 | shopt -u dotglob | |
92 | shopt -s expand_aliases | |
93 | shopt -s extglob | |
08404785 | 94 | if (( ${BASH_VERSINFO[0]} >= 4 )); then shopt -s globstar; fi |
83a3b1eb | 95 | shopt -s gnu_errfmt |
f617db13 | 96 | shopt -s histappend |
92e4caa8 | 97 | set -o histexpand |
f617db13 MW |
98 | shopt -s histreedit |
99 | shopt -u histverify | |
100 | shopt -s hostcomplete | |
101 | shopt -s huponexit | |
102 | shopt -s interactive_comments | |
103 | shopt -s lithist | |
104 | shopt -u mailwarn | |
105 | shopt -u nocaseglob | |
106 | shopt -u nullglob | |
107 | shopt -s promptvars | |
108 | shopt -u shift_verbose | |
109 | shopt -s sourcepath | |
83a3b1eb MW |
110 | HISTCONTROL=ignorespace:erasedups |
111 | ||
59c9c0e4 MW |
112 | ###-------------------------------------------------------------------------- |
113 | ### Finishing touches. | |
f617db13 | 114 | |
59c9c0e4 | 115 | ## Run any local hooks. |
74a53e28 | 116 | __mdw_source_if_exists "$HOME/.bashrc-local" |
59c9c0e4 MW |
117 | |
118 | ###----- That's all, folks -------------------------------------------------- | |
0d9bb87e | 119 | |
74a53e28 | 120 | esac |