public
Description: My configuration files for various applications
Homepage: http://mina86.com/
Clone URL: git://github.com/mina86/dot-files.git
mina86 (author)
Fri Oct 16 02:33:17 -0700 2009
commit  f20802d27bfc52da3bc4038a3042d3ccb058f875
tree    ee7f0243169d09a22185614288afec6b9cd6c5aa
parent  ba198f5843b077cbeff5ad542b8cccd33dc706d2
dot-files / shellrc
100644 232 lines (184 sloc) 4.435 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
## -*- shell-script -*-
## .shellrc -- global shell configuration file
## Copyright 2004-2008 by Michal Nazarewicz (mina86/AT/mina86.com)
## $Id: shellrc,v 1.13 2008/07/29 07:38:01 mina86 Exp $
##
 
# Not interactive?
[ X"${-#*i}" != X"$-" ] || return
 
# Hostname
if [ -z "$HOST" ]; then
HOST="$(hostname)"
HOST="${HOST%%.*}"
fi
_hostname=X"$HOST"
 
 
##
## If normal user -> umask 077; if super user -> umask 022
## Also, set TMOUT when super user and not running on pikus
##
if [ $(id -u) -eq 0 ] && [ "$_hostname" != Xpikus ]; then
umask 0022
TMOUT=1200
else
umask 0077
fi
 
 
##
## Some basic variables
##
[ -n "$UID" ] || UID="$(id -u)"
if [ -z "$USER" ]; then
if [ -n "$LOGNAME" ]
then USER="$LOGNAME"
else USER="$(id -un)"
fi
fi
[ -n "$LOGNAME" ] || LOGNAME="$USER"
[ -n "$HOME" ] || HOME="$(eval echo ~"$USER")"
 
 
 
##
## Prompt
##
 
# Default prompt (most likely will be overwritten in shell specific rc files)
if [ X"$UID" = X0 ]; then PS1='# '; else export PS1='$ '; fi
if [ -n "$SSH_CLIENT$SSH_CONNECTION" ]; then PS1="[$(hostname)]$PS1"; fi
export PS1
 
 
# Add title to terminals
case "$TERM" in xterm*|rxvt*)
printf '\033]2;%s@%s\07' "$USER" "$HOST"
esac
 
 
 
##
## Aliases & functions
##
 
# ls
unalias ls dir vdir ll l 2>/dev/null
alias ls='LANG=C ls $LS_OPTIONS'
alias ll='ls -l'
 
## make and change directory
unalias md 2>/dev/null
md () {
if [ $# -eq 0 ]; then
echo usage: 'md dir [ dir ... ]' >&2
return 1
else
mkdir -p -- "$@" && cd "$1"
fi
}
 
## List directory or content of file
l () {
if [ $# -eq 1 -a -f "$1" ]; then
less -- "$1"
elif [ $# -eq 2 -a x"$1" = x-- -a -f "$2" ]; then
less -- "$2"
else
ls "$@"
fi
}
 
# Other
if which run-emacs >/dev/null 2>&1; then
alias e=run-emacs
elif which emacsclient >/dev/null 2>&1; then
alias e='emacsclient -n'
fi
alias rmd=rmdir
which mpc >/dev/null 2>&1 && alias mpc="mpc --format '[[[%artist% <&%album%> ]|[%artist% - ]|[<%album%> ]]%title%]|[%file%]'"
if which git >/dev/null 2>&1; then
alias g=git
alias -- '+=git add'
fi
 
 
# Perl stuff
unalias pf pd 2>/dev/null
pf () {
if [ $# -eq 0 ]; then perldoc perlfunc; else perldoc -f "$@"; fi
}
 
pd () {
case "$1" in
perl*|*::*|-*|*[A-Z]*)
perldoc "$@"
;;
*)
perldoc "perl$1"
esac
}
 
 
# tinyapps stuff
if ! which xrun >/dev/null 2>&1; then
xrun () { "$@" & }
fi
if which cdiff >/dev/null 2>&1; then
alias diff=cdiff
fi
 
 
# More colors
if echo foo | grep --color=auto foo >/dev/null 2>/dev/null; then
alias grep='grep --color=auto'
alias fgrep='grep -F'
alias egrep='grep -E'
fi
 
 
 
##
## Variables
##
 
# For setting flags
if [ -e ~/bin/flags-do ]; then
unalias flags 2>/dev/null
flags () {
. ~/bin/flags-do "$@"
}
fi
 
 
# No need to set it once again
if [ -n "$MINA86RC" ]; then
unset _hostname
return
fi
export MINA86RC=done
 
 
# PATH
if ! echo "$PATH" | grep -F "$HOME/bin" -F '~/bin' >/dev/null 2>&1; then
if [ -d ~/code/tinyapps ]; then PATH="$HOME/code/tinyapps:$PATH"; fi
if [ -d ~/bin ]; then PATH="$HOME/bin:$PATH"; fi
if [ -d ~/bin64 ] && [ x"`uname -m`" = xx86_64 ]; then
PATH="$HOME/bin64:$PATH"
fi
fi
 
# Remove relative paths
PATH="$(echo ":$PATH:" | sed -e 's~:\(\([^/:][^:]*\)\?:\)*~:~g
s/^::*//
s/::*$//')"
export PATH
 
 
# Editor
[ -z "$EDITOR" ] && which nano >/dev/null 2>&1 && export EDITOR=nano VISUAL=nano
 
 
# less
if [ -n "$LESS" ] || which less >/dev/null 2>&1; then
export PAGER=less LESS=-MS
[ -x ~/bin/lesspipe ] && eval $(~/bin/lesspipe --install-lesspipe)
fi
 
 
# LaTeX
TEX=`which platex 2>/dev/null`
[ -n "$TEX" ] || TEX=`which latex 2>/dev/null`
[ -n "$TEX" ] || TEX=`which tex 2>/dev/null`
if [ -z "$TEX" ]; then
unset TEX
else
export TEX
fi
 
 
# LS options and colors
if [ -z "$LS_COLORS" ] && ls --color / >/dev/null 2>&1; then
if which dircolors >/dev/null 2>&1; then
if [ -f ~/.dir_colors ]; then eval "`dircolors -b ~/.dir_colors`"
elif [ -f /etc/DIR_COLORS ]; then eval "`dircolors -b /etc/DIR_COLORS`"
else eval "`dircolors -b`"
fi
elif [ -x ~/bin/dircolors ]; then
. ~/bin/dircolors
fi
fi
LS_OPTIONS="-FT0 --color=auto"
export LS_OPTIONS
 
 
# Various
export GZIP="-9n"
export FIGNORE=".o:~:.bak" CC=gcc CXX=g++
export LC_COLLATE=C LC_MESSAGES=en_GB
case "$_hostname" in (Xerwin|Xtuptus)
unset MAILCHECK MAIL
if [ x"`uname -m`" = xx86_64 ]; then
export ARCH=x86_64
else
export ARCH=i686
fi
flags init
esac
 
 
unset _hostname