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 MW |
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 | ###-------------------------------------------------------------------------- |
26 | ### Prompt hacking. | |
f617db13 | 27 | |
74a53e28 | 28 | __mdw_set_prompt_hacks () { |
15b95c26 MW |
29 | case "$TERM" in |
30 | linux*|screen*|xterm*|vt100*|eterm*) | |
59c3438f MW |
31 | case "$(tput bold)" in |
32 | "") bold="\[$(tput md)\]" unbold="\[$(tput me)\]" ;; | |
33 | *) bold="\[$(tput bold)\]" unbold="\[$(tput sgr0)\]" ;; | |
34 | esac | |
1273afa0 | 35 | gitcolour="\[$(tput setaf 6)\]" |
f00ae4fa MW |
36 | rccolour="\[$(tput setaf 1)\]" |
37 | uncolour="\[$(tput op)\]" | |
59c3438f MW |
38 | nl="\[\r\]" |
39 | ;; | |
15b95c26 | 40 | esac |
74a53e28 MW |
41 | host='\h' dir=' \w' |
42 | } | |
15b95c26 | 43 | |
74a53e28 MW |
44 | __mdw_before_cmd_hack () { |
45 | set -- $(history 1); shift | |
46 | __mdw_preexec "$*" | |
47 | } | |
e04a3368 | 48 | |
74a53e28 MW |
49 | ## Only bother if the shell is interactive. |
50 | if [ -t 0 ]; then | |
51 | PROMPT_DIRTRIM=5 | |
52 | __mdw_source_if_exists /usr/lib/git-core/git-sh-prompt | |
53 | __mdw_set_prompt_pieces | |
54 | PROMPT_COMMAND=__mdw_precmd | |
55 | PS0="\$(__mdw_before_cmd_hack)" | |
59c9c0e4 | 56 | fi |
15b95c26 | 57 | |
59c9c0e4 MW |
58 | ###-------------------------------------------------------------------------- |
59 | ### Other shell tweaking. | |
f617db13 | 60 | |
59c9c0e4 | 61 | ## Random shell tweaks. |
f617db13 MW |
62 | notify=1 |
63 | set -b | |
64 | shopt -u cdable_vars | |
65 | shopt -s cdspell | |
66 | shopt -s checkhash | |
67 | shopt -s checkwinsize | |
68 | shopt -s cmdhist | |
69 | shopt -u dotglob | |
70 | shopt -s expand_aliases | |
71 | shopt -s extglob | |
08404785 | 72 | if (( ${BASH_VERSINFO[0]} >= 4 )); then shopt -s globstar; fi |
83a3b1eb | 73 | shopt -s gnu_errfmt |
f617db13 MW |
74 | shopt -s histappend |
75 | shopt -s histreedit | |
76 | shopt -u histverify | |
77 | shopt -s hostcomplete | |
78 | shopt -s huponexit | |
79 | shopt -s interactive_comments | |
80 | shopt -s lithist | |
81 | shopt -u mailwarn | |
82 | shopt -u nocaseglob | |
83 | shopt -u nullglob | |
84 | shopt -s promptvars | |
85 | shopt -u shift_verbose | |
86 | shopt -s sourcepath | |
83a3b1eb MW |
87 | HISTCONTROL=ignorespace:erasedups |
88 | ||
59c9c0e4 MW |
89 | ###-------------------------------------------------------------------------- |
90 | ### Finishing touches. | |
f617db13 | 91 | |
59c9c0e4 | 92 | ## Run any local hooks. |
74a53e28 | 93 | __mdw_source_if_exists "$HOME/.bashrc-local" |
59c9c0e4 MW |
94 | |
95 | ###----- That's all, folks -------------------------------------------------- | |
0d9bb87e | 96 | |
74a53e28 | 97 | esac |