16b7e8e327ce6cf966497995284d868452943d5c
[profile] / bashrc
1 #
2 # $Id: .bashrc,v 1.6 1996/12/08 20:33:42 mdw Exp $
3 #
4 # Bash session things
5 #
6
7 if [ -z "$__mdw_bashrc" ]; then
8
9 __mdw_bashrc=done
10
11 [ -z "$__mdw_profile" -a -r $HOME/.bash_profile ] && . $HOME/.bash_profile
12 [ -r /etc/bashrc ] && . /etc/bashrc
13
14 # --- First of all, set up the prompt string ---
15
16 if [ -t 0 ]; then
17
18 if [ "$TERM" = "dumb" ]; then
19 if (( EUID == 0 )); then PS1="# "; else PS1="\$ "; fi
20 PS2="> "
21 PS4="+ "
22 else
23
24 case "$TERM" in
25 linux*|screen*|xterm*|vt100*)
26 bold='\[\e[1m\]' unbold='\[\e[m\]' nl='\[ \]' ;;
27 *)
28 bold='' unbold='' nl='' ;;
29 esac
30
31 if (( EUID == 0 )); then
32 left="«" right="»"
33 elif [ "$__mdw_tty" = "`tty`" ]; then
34 left="<" right=">"
35 else
36 left="[" right="]"
37 export __mdw_tty="`tty`"
38 fi
39
40 if [ -z "$SSH_CLIENT" ] &&
41 [ "$__mdw_sechost" != "`hostname`" ]
42 then
43 sec_l='(' sec_r=')'
44 fi
45
46 PS1="$nl$bold$left$sec_l\\h$sec_r \\w$right$unbold"
47 PS2="$PS1 $bold>$unbold "
48 fi
49
50 fi # is stdin a tty?
51
52 # --- Little preferences ---
53
54 notify=1
55 set -b
56 shopt -u cdable_vars
57 shopt -s cdspell
58 shopt -s checkhash
59 shopt -s checkwinsize
60 shopt -s cmdhist
61 shopt -u dotglob
62 shopt -s expand_aliases
63 shopt -s extglob
64 shopt -s histappend
65 shopt -s histreedit
66 shopt -u histverify
67 shopt -s hostcomplete
68 shopt -s huponexit
69 shopt -s interactive_comments
70 shopt -s lithist
71 shopt -u mailwarn
72 shopt -u nocaseglob
73 shopt -u nullglob
74 shopt -s promptvars
75 shopt -u shift_verbose
76 shopt -s sourcepath
77
78 # --- Set the CDPATH ---
79 #
80 # CDPATH=~/src:/usr/src:/usr/lib:/usr/share
81 # dots=..
82 # i=6
83 # while (( i > 0 )); do
84 # CDPATH=$CDPATH:$dots
85 # dots=$dots/..
86 # (( i -= 1 ))
87 # done
88 # CDPATH=$CDPATH:/
89
90 # --- Some colour `ls' support ---
91
92 [ "${TMPDIR+yes}" ] || eval `tmpdir -b`
93 if [ -x /usr/bin/dircolors -o -x /usr/local/bin/dircolors ] &&
94 [ "$TERM" != "dumb" ]; then
95 eval `dircolors -b ~/.dircolors`
96 else
97 unset LS_COLORS
98 fi
99
100 ls () {
101 if [ -t 1 ]; then
102 command ls $LS_OPTIONS ${LS_COLORS+--color=auto} "$@"
103 else
104 command ls "$@"
105 fi
106 }
107
108 # --- Set up some simple aliases ---
109
110 alias cx='chmod a+x'
111 alias which="command -v"
112 alias ssync="rsync -e ssh"
113 alias rootly="become -g0 root"
114 alias r=rootly
115 alias re="rootly sensible-editor"
116 alias pstree="pstree -Ghl"
117 alias cdtmp='cd ${TMPDIR-/tmp}'
118 alias pushtmp='pushd ${TMPDIR-/tmp}'
119 alias e="sensible-editor"
120 alias svn="svnwrap svn"
121 alias @="ssh"
122
123 # --- Make `xt' start an xterm, maybe logging into a remote host ---
124
125 xt () {
126 case "$1" in
127 @*)
128 local remote=${1#@} title
129 shift
130 if [ $# -gt 0 ]; then
131 title="xterm [$remote] $1"
132 else
133 title="xterm [$remote]"
134 fi
135 (xterm -title "$title" -e ssh $remote "$@" &)
136 ;;
137 *)
138 (xterm "$@" &)
139 ;;
140 esac
141 }
142
143 # --- Turning on and off core dumps ---
144
145 core () {
146 case "x$1" in
147 xon|xy|xyes)
148 ulimit -Sc `ulimit -Hc`
149 ;;
150 xoff|xn|xno)
151 ulimit -Sc 0
152 ;;
153 x)
154 local l=`ulimit -Sc`
155 case $l in
156 0) echo "Core dumps disabled" ;;
157 unlimited) echo "Core dumps enabled" ;;
158 *) echo "Core dump limit is $l blocks" ;;
159 esac
160 ;;
161 *)
162 echo >&2 "usage: core [yn]"
163 return 1
164 ;;
165 esac
166 }
167
168 # --- Fix `man' under Slowaris ---
169
170 case "$MACHTYPE" in
171 *solaris*)
172 man () {
173 declare -i i=0
174 declare arg
175 declare -a man
176
177 for arg; do
178 case "$arg" in [0-9]*) man[i+=1]="-s" ;; esac
179 man[i+=1]="$arg"
180 done
181 command man "${man[@]}"
182 }
183 ;;
184 esac
185
186 # --- For `root' use -- some simple molly-guards ---
187
188 if (( UID == 0 )); then
189 alias rm='rm -i' cp='cp -i' mv='mv -i'
190 set -o noclobber
191 fi
192
193 fi