chiark / gitweb /
dot/shell-rc: Only run tmpdir(1) if we actually found it.
[profile] / dot / bashrc
... / ...
CommitLineData
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.)
9case ${__mdw_bashrc+t} in
10 t) ;;
11 *) __mdw_bashrc=t
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.
19case ${__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###--------------------------------------------------------------------------
26### Prompt hacking.
27
28__mdw_set_prompt_hacks () {
29 case "$TERM" in
30 linux*|screen*|xterm*|vt100*|eterm*)
31 case "$(tput bold)" in
32 "") bold="\[$(tput md)\]" unbold="\[$(tput me)\]" ;;
33 *) bold="\[$(tput bold)\]" unbold="\[$(tput sgr0)\]" ;;
34 esac
35 gitcolour="\[$(tput setaf 6)\]"
36 rccolour="\[$(tput setaf 1)\]"
37 uncolour="\[$(tput op)\]"
38 nl="\[\r\]"
39 ;;
40 esac
41 host='\h' dir=' \w'
42}
43
44__mdw_before_cmd_hack () {
45 set -- $(history 1); shift
46 __mdw_preexec "$*"
47}
48
49## Only bother if the shell is interactive.
50if [ -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)"
56fi
57
58###--------------------------------------------------------------------------
59### Other shell tweaking.
60
61## Random shell tweaks.
62notify=1
63set -b
64shopt -u cdable_vars
65shopt -s cdspell
66shopt -s checkhash
67shopt -s checkwinsize
68shopt -s cmdhist
69shopt -u dotglob
70shopt -s expand_aliases
71shopt -s extglob
72if (( ${BASH_VERSINFO[0]} >= 4 )); then shopt -s globstar; fi
73shopt -s gnu_errfmt
74shopt -s histappend
75shopt -s histreedit
76shopt -u histverify
77shopt -s hostcomplete
78shopt -s huponexit
79shopt -s interactive_comments
80shopt -s lithist
81shopt -u mailwarn
82shopt -u nocaseglob
83shopt -u nullglob
84shopt -s promptvars
85shopt -u shift_verbose
86shopt -s sourcepath
87HISTCONTROL=ignorespace:erasedups
88
89###--------------------------------------------------------------------------
90### Finishing touches.
91
92## Run any local hooks.
93__mdw_source_if_exists "$HOME/.bashrc-local"
94
95###----- That's all, folks --------------------------------------------------
96
97esac