Bash Resource File
This is my current .bashrc file. Of course, this file is customized to my personal preferences, but there are settings and functions that would be useful for any UNIX-based system.
Just be sure to change directory paths and filenames if you plan on using this config.
Download:.bashrc
1 #!/bin/bash
2
3 setterm -initialize -blank 0 -cursor on
4
5 if [[ $- != *i* ]]; then
6 return
7 fi
8
9 if [ -f /etc/bashrc ]; then
10 . /etc/bashrc
11 fi
12
13 case "$-/${ENV_SET:-no}" in
14 *i*/no)
15 set -o ignoreeof
16 function exit {
17 . ~/.bash_logout
18 builtin exit
19 }
20 ;;
21 esac
22
23 eval `dircolors -b /etc/DIR_COLORS`
24
25 [ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion
26
27 #
28 # Environment Variables & Settings
29 ################################################################################
30
31 umask 022
32 ulimit -S -c 0
33
34 set -o notify
35 set -o noclobber
36 set +o nounset
37 #set -o xtrace # debugging
38
39 shopt -s cdspell
40 shopt -s cdable_vars
41 shopt -s checkhash
42 shopt -s checkwinsize
43 shopt -s cmdhist
44 shopt -s dotglob extglob
45 shopt -s histappend histreedit histverify
46 shopt -s hostcomplete
47 shopt -s no_empty_cmd_completion
48 shopt -s sourcepath
49 shopt -u mailwarn
50
51 unset MAILCHECK
52
53 PROMPT_COMMAND='history -a'
54
55 export HOST=$(hostname)
56 export OS=`uname`
57 export TIMEFORMAT=$'\nreal %3R\tuser %3U\tsys %3S\tpcpu %P\n'
58 export HISTSIZE=3000
59 export HISTFILESIZE=5000
60 export HISTIGNORE="&:bg:fg:h"
61 export HISTCONTROL=ignoredups
62 export TMOUT=6400
63
64 export PATH=~/Library/_bin:~/Library/_bin/eclipse:$PATH
65 export JAVA_HOME=/usr/lib/jvm/sun-jdk-1.6
66 #export LD_LIBRARY_PATH=/opt/gimp-devel/lib
67 #export PKG_CONFIG_PATH=/opt/gimp-devel/lib/pkgconfig
68 export CCACHE_DIR=/var/tmp/ccache
69
70 export XDG_MENU_PREFIX=gnome-
71 #export WINDOW_MANAGER=/usr/bin/sawfish
72 export EDITOR=/usr/bin/vim
73 export MYVIMRC=~/.vim/vimrc
74 export BROWSER=/usr/bin/firefox
75
76 export WWW_HOME=http://68.147.60.50/devel/
77 export GDK_USE_XFT=1
78 export MOZ_DISABLE_PANGO=1
79
80 export LESS=-R
81
82 #
83 # Prompt
84 ################################################################################
85
86 PS1="\n `date "+%H:%M%n"` \[\033[1;32m\]\$(/usr/bin/tty | /bin/sed -e 's:/dev/::') \
87 \[\033[1;36m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files \
88 \[\033[1;33m\](\$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b)\[\033[0m\] \
89 \[\033[1;36m\]\w \n"
90 case `id -u` in
91 0) PS1="${PS1}\[\033[1;31m\]\u@\h \[\033[1;31m\]::\[\033[0m\] ";;
92 *) PS1="${PS1}\[\033[0;36m\]\u@\h \[\033[0;36m\]=>\[\033[0m\] ";;
93 esac
94
95 ## File & Directory Controls
96 ##############################################
97 alias ls="ls -Abh --color=always"
98 alias lsl="ls -l"
99 alias df="df -kTh"
100 alias cdca="cd ~/Library/Code/Web-based/Applications"
101 alias cdw="cd ~/Projects/www/htdocs"
102 alias srca="cd ~/Projects/Sources/Applications"
103 alias srct="cd ~/Projects/Sources/Theming"
104
105 ## Administration
106 ##############################################
107 alias s="su - root"
108 alias S="su"
109
110 ## Editing
111 ##############################################
112 alias n="nano -w"
113 alias v="vim"
114 alias b="v ~/.bashrc"
115 alias gr="v /boot/grub/grub.conf"
116 alias grm="mount /boot && v /boot/grub/grub.conf && umount /boot"
117 alias mk="v /etc/make.conf"
118 alias pu="v /etc/portage/package.use"
119 alias cpu="cat /etc/portage/package.use | grep $1"
120 alias xo="v /etc/X11/xorg.conf"
121 alias lynx="lynx -accept_all_cookies"
122
123 ## System Installation & Upgrade
124 ##############################################
125 alias svng="svn co http://svn.gnome.org/svn/$1 $2"
126 alias upf="fc-cache -f -v"
127 alias emerge="emerge -v"
128 alias e="emerge -v"
129 alias eup="e --sync && e world -up"
130 alias eudp="e --sync && e world --newuse -uDp"
131 alias eu="e world -u"
132 alias eud="e world --newuse -uD"
133
134 ## Environment
135 ##############################################
136 alias c="clear"
137 case `id -u` in
138 0) alias en="env-update && source /etc/profile";;
139 *) alias en="source /etc/profile";;
140 esac
141 alias et="etc-update"
142 alias dp="dispatch-conf"
143 alias edf="rm -rf /usr/portage/distfiles/*"
144 alias his="history | grep $1"
145
146 ## Applications
147 ##############################################
148 alias x="startx"
149 alias ap="/etc/init.d/apache2 restart"
150 alias sq="/etc/init.d/mysql restart"
151 alias al="/etc/init.d/alsasound restart"
152 alias mysql="mysql -u jason -p"
153 alias mysqlr="mysql -u root -p"
154 alias kgp="killall -9 gnome-panel"
155 alias burndisc="cdrecord -v -pad -speed=16 dev=/dev/sr0 $1"
156 alias ga="gnome-appearance-properties"
157 alias fl="flac2mp3 `pwd` `pwd`"
158 alias www="lynx http://$1"
159 alias wpinstall="svn co http://svn.automattic.com/wordpress/trunk/ ."
160
161 ## Directories
162 ##############################################
163 alias mg='cd ~/Media/Music && find ./ -type d -exec sh -c "mp3gain \"{}\"/*.mp3" \;'
164 alias mgfull='cd ~/Media/Music && find ./ -type d -exec sh -c "mp3gain -cTpfr \"{}\"/*.mp3" \;'
165
166 ## Networking
167 ##############################################
168 alias rsw="rs ~/Projects/www/"
169 alias pi="ping -c 3 www.gentoo.org"
170 alias jdm="ssh jdmlabs@espresso.dreamhost.com"
171
172 #
173 # Functions
174 ################################################################################
175
176 ### REBOOT
177 function rb() {
178 shutdown -r now
179 }
180
181 ### SHUTDOWN
182 function sd() {
183 shutdown -h now
184 }
185
186 ### ADDUSE
187 function adduse() {
188 echo $1 >> /etc/portage/package.use
189 sort /etc/portage/package.use -o /etc/portage/package.use
190 }
191
192 ### ADDMASK
193 function addmask() {
194 echo $1 >> /etc/portage/package.mask
195 sort /etc/portage/package.mask -o /etc/portage/package.mask
196 }
197
198 ### UNMASK
199 function unmask() {
200 echo $1 >> /etc/portage/package.unmask
201 sort /etc/portage/package.unmask -o /etc/portage/package.unmask
202 }
203
204 ### ADDKW
205 function addkw() {
206 echo $1 >> /etc/portage/package.keywords
207 sort /etc/portage/package.keywords -o /etc/portage/package.keywords
208 }
209
210 ### COMPILE & INSTALL KERNEL
211 function mkk() {
212 local usage="mkk < kernel_version >"
213
214 if [ "$#" -lt 1 ]; then
215 echo "$usage"
216 return;
217 fi
218
219 cd /usr/src/linux
220 mount /boot
221 env-update
222 source /etc/profile
223 make
224 make modules_install
225 cp .config ../config-gentoo
226 cd /boot
227 cp /usr/src/linux/System.map ./System.map
228 cp /usr/src/linux/arch/x86_64/boot/bzImage ./$1
229
230 echo "\n\n\n\nHooray! :)\n\n\n"
231 echo "I have successfully compiled the kernel and copied '$1' to the /boot dir\n\n"
232
233 cd /usr/src/linux
234 lsl /boot
235 umount /boot
236 }
237
238 ### RSYNC LAPTOP
239 function rs() {
240 dir=$1
241 rsync -arvuz $dir icarus:$dir
242 }
243
244 ### GOOGLE SEARCH
245 function gg() {
246 SEARCH=$(echo $* | sed -e 's/ /\%20/g')
247 www www.google.com/search?q="$SEARCH"
248 }
249
250 ### RENAME FILES
251 function rename() {
252 criteria=$1
253 re_match=$2
254 replace=$3
255
256 for i in $( ls *$criteria* );
257 do
258 src=$i
259 tgt=$(echo $i | sed -e "s/$re_match/$replace/")
260 mv $src $tgt
261 done
262 }
263
264 ### RENAME EXTENSION
265 function renameext() {
266 for f in *.$1; do
267 mv $f $f%$1}$2
268 done
269 }
270
271 ### MUSIC CLEAN
272 function mc() {
273 cd ~/Media/Music
274 find ./ -type f -name ".directory" -print0 | xargs -0 rm -f
275 find ./ -type d -empty -print0 | xargs -0 rmdir
276 cd
277 }
278
279 ### WINDOWS CLEANER
280 function windowscleaner() {
281 cd ~/Media/Music
282 find ./ -type f -name "desktop.ini" -print0 | xargs -0 rm -f
283 find ./ -type d -empty -print0 | xargs -0 rmdir
284 cd
285 }
Download:.bashrc