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