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.) | |
74a53e28 MW |
9 | case ${__mdw_shellrc+t} in |
10 | t) ;; | |
11 | *) __mdw_shellrc=done | |
12 | ||
13 | ## Fetch the common configuration. | |
14 | . "$HOME/.shell-rc" | |
f617db13 | 15 | |
59c9c0e4 MW |
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. | |
74a53e28 MW |
19 | case ${__mdw_profile+t} in t) ;; *) . "$HOME/.profile" ;; esac |
20 | __mdw_source_if_exists /etc/bashrc | |
f617db13 | 21 | |
5e662c38 | 22 | ## Completion. |
74a53e28 | 23 | __mdw_source_if_exists /etc/bash_completion "$HOME/.bash_completion" |
5e662c38 | 24 | |
59c9c0e4 MW |
25 | ## Set the temporary directory again. (If we've switched users, we'll want a |
26 | ## different temporary directory.) | |
74a53e28 | 27 | case ${TMPDIR+t} in t) ;; *) eval $(tmpdir -b); esac |
59c9c0e4 MW |
28 | |
29 | ###-------------------------------------------------------------------------- | |
30 | ### Prompt hacking. | |
f617db13 | 31 | |
74a53e28 | 32 | __mdw_set_prompt_hacks () { |
15b95c26 MW |
33 | case "$TERM" in |
34 | linux*|screen*|xterm*|vt100*|eterm*) | |
59c3438f MW |
35 | case "$(tput bold)" in |
36 | "") bold="\[$(tput md)\]" unbold="\[$(tput me)\]" ;; | |
37 | *) bold="\[$(tput bold)\]" unbold="\[$(tput sgr0)\]" ;; | |
38 | esac | |
1273afa0 | 39 | gitcolour="\[$(tput setaf 6)\]" |
f00ae4fa MW |
40 | rccolour="\[$(tput setaf 1)\]" |
41 | uncolour="\[$(tput op)\]" | |
59c3438f MW |
42 | nl="\[\r\]" |
43 | ;; | |
15b95c26 | 44 | esac |
74a53e28 MW |
45 | host='\h' dir=' \w' |
46 | } | |
15b95c26 | 47 | |
74a53e28 MW |
48 | __mdw_before_cmd_hack () { |
49 | set -- $(history 1); shift | |
50 | __mdw_preexec "$*" | |
51 | } | |
e04a3368 | 52 | |
74a53e28 MW |
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)" | |
59c9c0e4 | 60 | fi |
15b95c26 | 61 | |
59c9c0e4 MW |
62 | ###-------------------------------------------------------------------------- |
63 | ### Other shell tweaking. | |
f617db13 | 64 | |
59c9c0e4 | 65 | ## Random shell tweaks. |
f617db13 MW |
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 | |
08404785 | 76 | if (( ${BASH_VERSINFO[0]} >= 4 )); then shopt -s globstar; fi |
83a3b1eb | 77 | shopt -s gnu_errfmt |
f617db13 MW |
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 | |
83a3b1eb MW |
91 | HISTCONTROL=ignorespace:erasedups |
92 | ||
59c9c0e4 MW |
93 | ###-------------------------------------------------------------------------- |
94 | ### Finishing touches. | |
f617db13 | 95 | |
59c9c0e4 | 96 | ## Run any local hooks. |
74a53e28 | 97 | __mdw_source_if_exists "$HOME/.bashrc-local" |
59c9c0e4 MW |
98 | |
99 | ###----- That's all, folks -------------------------------------------------- | |
0d9bb87e | 100 | |
74a53e28 | 101 | esac |