chiark / gitweb /
dot/bashrc, dot/zshrc: Do highlighting when `TERM' is `putty...'.
[profile] / dot / bashrc
CommitLineData
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 9case ${__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
19case ${__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 29 case "$TERM" in
8a075bd7 30 linux*|screen*|xterm*|putty*|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)\]"
8a075bd7
MW
38 nl="\[
39\]"
59c3438f 40 ;;
15b95c26 41 esac
74a53e28
MW
42 host='\h' dir=' \w'
43}
15b95c26 44
74a53e28
MW
45__mdw_before_cmd_hack () {
46 set -- $(history 1); shift
47 __mdw_preexec "$*"
48}
e04a3368 49
74a53e28
MW
50## Only bother if the shell is interactive.
51if [ -t 0 ]; then
52 PROMPT_DIRTRIM=5
53 __mdw_source_if_exists /usr/lib/git-core/git-sh-prompt
54 __mdw_set_prompt_pieces
55 PROMPT_COMMAND=__mdw_precmd
56 PS0="\$(__mdw_before_cmd_hack)"
59c9c0e4 57fi
15b95c26 58
59c9c0e4
MW
59###--------------------------------------------------------------------------
60### Other shell tweaking.
f617db13 61
59c9c0e4 62## Random shell tweaks.
f617db13
MW
63notify=1
64set -b
65shopt -u cdable_vars
66shopt -s cdspell
67shopt -s checkhash
68shopt -s checkwinsize
69shopt -s cmdhist
70shopt -u dotglob
71shopt -s expand_aliases
72shopt -s extglob
08404785 73if (( ${BASH_VERSINFO[0]} >= 4 )); then shopt -s globstar; fi
83a3b1eb 74shopt -s gnu_errfmt
f617db13 75shopt -s histappend
92e4caa8 76set -o histexpand
f617db13
MW
77shopt -s histreedit
78shopt -u histverify
79shopt -s hostcomplete
80shopt -s huponexit
81shopt -s interactive_comments
82shopt -s lithist
83shopt -u mailwarn
84shopt -u nocaseglob
85shopt -u nullglob
86shopt -s promptvars
87shopt -u shift_verbose
88shopt -s sourcepath
83a3b1eb
MW
89HISTCONTROL=ignorespace:erasedups
90
59c9c0e4
MW
91###--------------------------------------------------------------------------
92### Finishing touches.
f617db13 93
59c9c0e4 94## Run any local hooks.
74a53e28 95__mdw_source_if_exists "$HOME/.bashrc-local"
59c9c0e4
MW
96
97###----- That's all, folks --------------------------------------------------
0d9bb87e 98
74a53e28 99esac