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 | |
3b41df91 MW |
13 | ###-------------------------------------------------------------------------- |
14 | ### Common shell configuration. | |
15 | ||
74a53e28 | 16 | . "$HOME/.shell-rc" |
f617db13 | 17 | |
3b41df91 MW |
18 | ###-------------------------------------------------------------------------- |
19 | ### Other preliminaries. | |
20 | ||
59c9c0e4 MW |
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. | |
74a53e28 MW |
24 | case ${__mdw_profile+t} in t) ;; *) . "$HOME/.profile" ;; esac |
25 | __mdw_source_if_exists /etc/bashrc | |
f617db13 | 26 | |
5e662c38 | 27 | ## Completion. |
74a53e28 | 28 | __mdw_source_if_exists /etc/bash_completion "$HOME/.bash_completion" |
5e662c38 | 29 | |
59c9c0e4 MW |
30 | ###-------------------------------------------------------------------------- |
31 | ### Prompt hacking. | |
f617db13 | 32 | |
74a53e28 | 33 | __mdw_set_prompt_hacks () { |
15b95c26 | 34 | case "$TERM" in |
8a075bd7 | 35 | linux*|screen*|xterm*|putty*|vt100*|eterm*) |
59c3438f MW |
36 | case "$(tput bold)" in |
37 | "") bold="\[$(tput md)\]" unbold="\[$(tput me)\]" ;; | |
38 | *) bold="\[$(tput bold)\]" unbold="\[$(tput sgr0)\]" ;; | |
39 | esac | |
1273afa0 | 40 | gitcolour="\[$(tput setaf 6)\]" |
f00ae4fa MW |
41 | rccolour="\[$(tput setaf 1)\]" |
42 | uncolour="\[$(tput op)\]" | |
9bd5ab69 | 43 | nl="\[\r\]" |
59c3438f | 44 | ;; |
15b95c26 | 45 | esac |
74a53e28 MW |
46 | host='\h' dir=' \w' |
47 | } | |
15b95c26 | 48 | |
74a53e28 MW |
49 | __mdw_before_cmd_hack () { |
50 | set -- $(history 1); shift | |
51 | __mdw_preexec "$*" | |
52 | } | |
e04a3368 | 53 | |
74a53e28 MW |
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)" | |
59c9c0e4 | 61 | fi |
15b95c26 | 62 | |
59c9c0e4 MW |
63 | ###-------------------------------------------------------------------------- |
64 | ### Other shell tweaking. | |
f617db13 | 65 | |
59c9c0e4 | 66 | ## Random shell tweaks. |
f617db13 MW |
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 | |
08404785 | 77 | if (( ${BASH_VERSINFO[0]} >= 4 )); then shopt -s globstar; fi |
83a3b1eb | 78 | shopt -s gnu_errfmt |
f617db13 | 79 | shopt -s histappend |
92e4caa8 | 80 | set -o histexpand |
f617db13 MW |
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 | |
83a3b1eb MW |
93 | HISTCONTROL=ignorespace:erasedups |
94 | ||
59c9c0e4 MW |
95 | ###-------------------------------------------------------------------------- |
96 | ### Finishing touches. | |
f617db13 | 97 | |
59c9c0e4 | 98 | ## Run any local hooks. |
74a53e28 | 99 | __mdw_source_if_exists "$HOME/.bashrc-local" |
59c9c0e4 MW |
100 | |
101 | ###----- That's all, folks -------------------------------------------------- | |
0d9bb87e | 102 | |
74a53e28 | 103 | esac |