# .bashrc # User specific aliases and functions # Don't forget this is published straight on the Web export EDITOR=emacs export DICTIONARY="british" export HISTSIZE=10000 export HISTFILESIZE=10000 export TZ="America/Toronto" # this one from my final-year project but a handy pattern nonetheless # I just tweak it for whatever doc I am working on presently alias p=pine alias psqlg='psql gallery -Unobody' alias psqlfive='psql fivehops -Ufivehops' alias psqlad='psql adrideo -Uadrideo' alias psqlmuse='psql virtualmuse -Unobody' alias psqlhmh='psql hmhnegotiants -U hmhnegotiants' alias psqlrob='psql robblackhurst -Unobody' alias psqlnot='psql notcontrary -Unobody' alias psqlv='psql videdot -Unobody' alias psqlvs='psql ventureshare -Uventureshare' alias psqll='psql lookuptv -Unobody' alias psqllv='psql lifestylevideo -Ulifestylevideo' alias psqlp='psql performdb -Uperformdb' alias psqlb='psql benhenley -Ubenhenley' alias psqlf='psql fabians -Ufabians' alias psqltv='psql feedmytv -Ufeedmytv' alias psqlma='psql maryargent -Umaryargent' alias psqlmed='psql media -Umedia' alias psqlmet='psql meta -Unobody' alias psqlm='psql magicmobilemedia -Umagicmobilemedia' alias ack='ack-grep' alias lhead='lynx -head -dump' alias lsource='lynx -source -dump' alias rand='expr 1 + `date +%s` / 1000 % ' alias acroprint='acroread -toPostScript -size a4 -shrink -level2' alias rot13="tr A-Za-z N-ZA-Mn-za-m" alias msync='rsync --exclude .DS_Store -Par' alias aesopcvs='CVSROOT='\''cvsuser.doc.ic.ac.uk:/vol/aesop/cvsroot'\'' cvs' # Needs more to handle postgres' serial columns which get structured, named indices alias rejig-data-model='grep -i create | sed -r -e "s/create/drop/gi" -e "s/[[:space:]]*\([[:space:]]*$/;/g" -e "s/^drop (unique)? (index[[:space:]][^[:space:]]+).*$/drop \\2;/ig" | tac' # whois-log is a separate script that logs the request # and flags whether it was available or not. This lets # me look back through what I was thinking about, and spot # useful names in future. alias whois='whois-log' alias ww='watch -n 10 w' function eps2pdf () { for arg; do echo "$arg => ${arg/eps/pdf}"; epstopdf $arg; done } function pine () { command pine $* && postponed-msgs } function grouplist () { groups $* | sed -r -e 's;^([^[:space:]]+) : ;\1: ;' -e 's;[[:space:]]+;\n\t;g' } function refwget () { wget --header 'Referer: `echo "$*" | sed -r -e "s/[^/]+$//"`' $* } function words () { lynx -dump -nolist "$*" | wc -w } function mkcd () { mkdir -p "$*" && cd "$*" } function cd () { if [ -z "$*" ]; then builtin cd elif [ -f "$*" ]; then $EDITOR $* else builtin cd "$*" fi } function postponed-msgs () { POSTPONED_COUNT=`grep "^Content-Type" ~/mail/postponed-msgs 2>/dev/null | wc -l` if [ 1 -lt $POSTPONED_COUNT ]; then echo "$POSTPONED_COUNT postponed, half-written messages" elif [ 0 -lt $POSTPONED_COUNT ]; then echo "$POSTPONED_COUNT postponed, half-written message" fi } CVSROOT=/home/cvs CVS_RSH=ssh export CVSROOT export CVS_RSH # I use this in my bash prompt, so that I can immediately see how # many suspended jobs I have, the line from my ~/.bash_profile is: # PS1='[$(stopped_jobs)\u@\h \W]\$ ' # which runs it every time, rather than once on sourcing the profile # (which is what backticks will get you, typically) function stopped_jobs { #Would rather use 'jobs -s' but that's not in the version everywhere I run this NUM_STOPPED=`jobs | grep "Stop" | wc -l | cut -d " " -f 7-` if [ $NUM_STOPPED -gt 0 ]; then echo "$NUM_STOPPED/" fi } # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi