-
Notifications
You must be signed in to change notification settings - Fork 13
/
.bashrc
245 lines (176 loc) · 4.21 KB
/
.bashrc
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
233
234
235
236
237
238
239
240
241
242
243
244
245
# Adam's .bashrc
#
# for those shitty times when zsh isn't to hand
#
# $Id$
# .bashrc is invoked by non-login interactive shells and by login
# interactive shells via a hook in my .bash_profile; also when bash is
# invoked from rshd (or similar?)
: .bashrc starts # for debugging with -x
# Allow disabling of all meddling with the environment
[ -n "$INHERIT_ENV" ] && return 0
# {{{ Environment
[ -r ~/.bashenv ] && . ~/.bashenv
# }}}
sh_load_status .bashrc
# {{{ source /etc/bashrc
if [ -f /etc/bashrc ]; then
sh_load_status "/etc/bashrc"
. /etc/bashrc
else
[ -r $ZDOTDIR/.sysbashrc ] && . $ZDOTDIR/.sysbashrc
fi
# }}}
##############################################################################
# Only interactive stuff follows below.
if [ -n "$shell_interactive" ]; then
# {{{ Try to switch shell
# For some weird reason this needs to be done after sourcing
# /etc/bashrc if the latter contains an stty, otherwise if
# the switched to shell exits non-zero, execution through this
# file proceeds (possibly without a tty as a result of the exit?)
# and the stty hangs.
# "" is to force shell choice from ~/.preferred_shell
[ -r ~/.switch_shell ] && . ~/.switch_shell ""
# }}}
# {{{ Save a large history
HISTSIZE=10000
HISTFILESIZE=10000
HISTTIMEFORMAT="%F %H:%M:%S "
# }}}
# {{{ ls colours
if which dircolors >/dev/null 2>&1 && [ -e ~/.dircolors ]; then
sh_load_status "dircolors"
eval `dircolors -b ~/.dircolors`
fi
# }}}
# {{{ Key bindings
sh_load_status "key bindings"
set -o emacs # vi sucks ;-)
bind '"\ep":history-search-backward'
bind '"\en":history-search-forward'
bind '"\e\C-i":dynamic-complete-history'
# }}}
# {{{ Prompt
sh_load_status "prompt"
PS1="\u@\h \[\033[1m\]\\w\[\033[0m\] \\$ "
# This only helps when the non-interactive script is being run from an
# interactive bash, because this file doesn't get run for
# non-interactive shells. In zsh, PS4 is set to something else, so
# use my bx function instead.
export PS4="+\D{%Y/%m/%d %T} \${BASH_SOURCE/\$HOME/\~}@\${LINENO}(\${FUNCNAME[0]}): "
# }}}
# {{{ Aliases and functions
sh_load_status "aliases/functions"
# {{{ ls aliases
if ls -F --color >&/dev/null; then
alias ls='command ls -F --color'
elif ls -F >&/dev/null; then
alias ls='command ls -F'
elif ls --color >&/dev/null; then
alias ls='command ls --color'
fi
# jeez I'm lazy ...
alias l='ls -lh'
alias ll='ls -l'
alias la='ls -lha'
alias lla='ls -la'
alias lsa='ls -ah'
alias lsd='ls -d'
alias lsh='ls -dh .*'
alias lsr='ls -Rh'
alias ld='ls -ldh'
alias lt='ls -lth'
alias llt='ls -lt'
alias lrt='ls -lrth'
alias llrt='ls -lrt'
alias lart='ls -larth'
alias llart='ls -lart'
alias lr='ls -lRh'
alias llr='ls -lR'
alias lsL='ls -L'
alias lL='ls -Ll'
alias lS='ls -lSh'
alias lrS='ls -lrSh'
alias llS='ls -lS'
alias llrS='ls -lrS'
alias sl=ls # often screw this up
# }}}
# {{{ which/where
alias wh='type -a'
# }}}
# {{{ File management
# {{{ Changing/making/removing directory
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
alias cd.....='cd ../../../..'
alias cd......='cd ../../../../..'
z () {
cd ~/"$@"
}
alias md='mkdir -p'
alias rd=rmdir
alias dirs='dirs -v'
alias d=dirs
# Don't need this because auto_pushd is set
#alias pu=pushd
alias po=popd
# }}}
# {{{ finding out disk hogs
# {{{ du1 (du with depth 1)
du1 () {
du "$@" | egrep -v '/.*/'
# Another idea from Bart Schaefer, which I need to fix
# to take parameters
#du -s *(/)
}
# }}}
# }}}
# }}}
# {{{ Job/process control
alias j='jobs -l'
# }}}
# {{{ Terminals
alias vx='export TERM=xterm-color'
alias v1='export TERM=vt100'
alias v2='export TERM=vt220'
alias cls='clear'
alias term='echo $TERM'
# }}}
# {{{ History
alias h='history $LINES'
# }}}
# {{{ Other users
alias f=finger
# }}}
# {{{ Other programs
# {{{ less
if ! which less >&/dev/null; then
alias less=more
fi
alias v=less
# }}}
# {{{ editors
if which emacs >/dev/null 2>&1; then
e () {
emacs "$@" 2>&1 &
}
fi
# }}}
# {{{ ftp
if which lftp >&/dev/null; then
alias ftp=lftp
elif which ncftp >&/dev/null; then
alias ftp=ncftp
fi
# }}}
# {{{ watching log files
alias tf='less +F'
# }}}
# }}}
# }}}
echo -e -n "\r\e[0K"
fi
. $ZDOT_RUN_HOOKS .bashrc.d
: .bashrc ends # for debugging with -x