# ~/.bash_profile: This file contains global defaults used by # all Bourne (and related) shells. This file can be copied freely # to other hosts. # Set beautiful colors :) standard="\[\033[0m\]" black="\[\033[0;30m\]" darkgrey="\[\033[1;30m\]" darkred="\[\033[0;31m\]" red="\[\033[1;31m\]" darkgreen="\[\033[0;32m\]" green="\[\033[1;32m\]" darkyellow="\[\033[0;33m\]" yellow="\[\033[1;33m\]" darkblue="\[\033[0;34m\]" blue="\[\033[1;34m\]" darkpurple="\[\033[0;35m\]" purple="\[\033[1;35m\]" darkcyan="\[\033[0;36m\]" cyan="\[\033[1;36m\]" grey="\[\033[0;37m\]" white="\[\033[1;37m\]" # Green by default usercolor=$green # Set the values for some environment variables: export LS_OPTIONS='-Fh --color=always --group-directories-first' # Editing export VISUAL="/usr/bin/vim" export EDITOR="/usr/bin/vim" # History export HISTCONTROL=erasedups export HISTSIZE=10000 # Force Perl into UTF-8 mode export PERL_UNICODE=S # Set the default system $PATH: PATH="/bin:/usr/bin:/usr/local/bin:/lib:/usr/lib:/usr/local/lib:~/scripts/:." # For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in # the $PATH. Some means of connection don't add these by default (sshd comes # to mind). if [ "`id -u`" = "0" ]; then echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null if [ ! $? = 0 ]; then PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH fi fi # Set default POSIX locale: export LC_ALL="en_US.utf-8" export LANG="en_US.utf-8" # Set some aliases alias 444='find . -type f -exec chmod 444 {} \;' alias 555='find . -type d -exec chmod 555 {} \;' alias 644='find . -type f -exec chmod 644 {} \;' alias 664='find . -type f -exec chmod 664 {} \;' alias 755='find . -type d -exec chmod 755 {} \;' alias 775='find . -type d -exec chmod 775 {} \;' alias cp='cp -i' alias duh='du -h --max-depth=1' alias finddead='find . -type l | xargs file|grep "broken symbolic"|sed "s/^\|: *broken symbolic.*$/\"/g"' alias l='ls $LS_OPTIONS -la' alias la='ls $LS_OPTIONS -a' alias ll='ls $LS_OPTIONS -l' alias ls='ls $LS_OPTIONS' alias mv='mv -i' alias nonascii="perl -nwe 'print if /[^[:ascii:]]/'" alias pie='perl -pi -e $*' alias ping='ping -c4' alias psx='ps aux --forest' alias remoteip="set|grep SSH_CONNECTION|awk '{print \$1}'|sed \"s/.*'//\"" alias svnst='svn st|grep -vE "\buploads\b|\bcache\b"' alias tua='netstat -tua' alias tuna='netstat -tuna' alias vimdiff='vimdiff -c"windo set wrap" $*' # Set up prompt ttynr=$(tty|cut -c9-11) # Root gets red if [ $(whoami) = 'root' ]; then usercolor=$red fi # Show smiley indicating success/failure smiley () { if [ $? == 0 ]; then echo ':-)';else echo ':-('; fi; } # Grep C/CSS/PHP/Perl code cgrep () { find . -type f -iname "*.c" -print -o -iname "*.h" -print | xargs grep -HrinE "$*"; } cgrepf () { find . -type f -iname "*.c" -print -o -iname "*.h" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq; } cgrepv () { vim `find . -type f -iname "*.c" -print -o -iname "*.h" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq`; } cppgrep () { find . -type f -iname "*.cpp" -print -o -iname "*.h" -print | xargs grep -HrinE "$*"; } cppgrepf () { find . -type f -iname "*.cpp" -print -o -iname "*.h" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq; } cppgrepv () { vim `find . -type f -iname "*.cpp" -print -o -iname "*.h" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq`; } cssgrep () { find . -type f -iname "*.css" -print | xargs grep -HrinE "$*"; } cssgrepf () { find . -type f -iname "*.css" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq; } cssgrepv () { vim `find . -type f -iname "*.css" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq`; } htmlgrep () { find . -type f -iname "*.html" -print | xargs grep -HrinE "$*"; } htmlgrepf () { find . -type f -iname "*.html" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq; } htmlgrepv () { vim `find . -type f -iname "*.html" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq`; } jsgrep () { find . -type f -iname "*.js" -print | xargs grep -HrinE "$*"; } jsgrepf () { find . -type f -iname "*.js" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq; } jsgrepv () { vim `find . -type f -iname "*.js" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq`; } phpgrep () { find . -type f -iname "*.php" -print | xargs grep -HrinE "$*"; } phpgrepf () { find . -type f -iname "*.php" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq; } phpgrepv () { vim `find . -type f -iname "*.php" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq`; } perlgrep () { find . -type f -iname "*.p[lm]" -print | xargs grep -HrinE "$*"; } perlgrepf () { find . -type f -iname "*.p[lm]" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq; } perlgrepv () { vim `find . -type f -iname "*.p[lm]" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq`; } sassgrep () { find . -type f -iname "*.sass" -print | xargs grep -HrinE "$*"; } sassgrepf () { find . -type f -iname "*.sass" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq; } sassgrepv () { vim `find . -type f -iname "*.sass" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq`; } shgrep () { find . -type f -iname "*.sh" -print | xargs grep -HrinE "$*"; } shgrepf () { find . -type f -iname "*.sh" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq; } shgrepv () { vim `find . -type f -iname "*.sh" -print | xargs grep -HrinE "$*"|perl -pe 's/:.*//'|uniq`; } # Show syntax highlighting for SVN diff svndiff () { svn diff --diff-cmd diff -x -uw $@ | colordiff | less -R; } # Show log when updating SVN svnup () { revision1="`svn info|grep Revision|expr \`awk '{ print $2 }'\` + 1`"; svn up; revision2="`svn info|grep Revision|awk '{ print $2 }'`"; if [ $revision1 -le $revision2 ]; then svn log -r$revision1:$revision2 -v; fi } # Include system-wide definitions if [ -e /etc/userconfig/.bash_include ]; then . /etc/userconfig/.bash_include fi # Include user definitions if [ -e ~/.bash_include ]; then . ~/.bash_include fi # Set up prompt PS1="\$(smiley) \t "$usercolor"\u"$standard"@"$hostcolor$HOSTNAME$standard"@"$blue"tty"$ttynr$standard":\w>" PS2='> ' export PATH PS1 PS2