# .bashrc if [ "$PS1" ]; then if [ -x $HOME/bin/vim ] ; then export EDITOR=$HOME/bin/vim elif ( which vim > /dev/null ) ; then export EDITOR=vim fi export PAGER=less export VPAGER="vim -R -" export RSYNC_RSH=ssh export MAIL="${HOME}/mail/inbox" #export MAIL="/var/mail/bart" export CVS_RSH=ssh export CVSREAD=yes # export NNTPSERVER=nntp.rchrd.phub.net.cable.rogers.com # ---- time ------------------------------------------------------------ export TIME="\n%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)\n%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps" alias t="/usr/bin/time" #function d() { if test -d "$1" ; then ls $@ ; else cat $@ ; fi ; } function wt() { while true ; do ( $@ ) ; sleep 1 ; clear ; done ; } function tt() { tcsh -c "time $*" ; } function yyyymmdd { date +%Y%m%d ; } function yyyymmdd-hhmmss { date +%Y%m%d-%H%M%S ; } alias ymd=yyyymmdd alias ymd-hms=yyyymmdd-hhmmss # ---- paging ------------------------------------------------------------ function least() { declare -a lines if ! [ -z "$@" ] ; then cat $@ | least return 0 fi if [ -z "$LINES" ] || ! ( echo $LINES | grep -q '^[0-9]\+$' ) ; then LINES=20 fi function dump_array () { for n in `seq 1 "${#lines[@]}"` ; do echo "${lines[$n]}" done } #pre_IFS=$IFS #IFS= while read x ; do #IFS=$pre_IFS lines[((${#lines[@]}+1))]="$x" if [ "${#lines[@]}" -ge $LINES ] ; then ( dump_array ; cat ) | $VPAGER exit 0 fi done #IFS=$pre_IFS dump_array } #function v() { $@ | vim -R - ; } function v() { $@ | least ; } function vv() { $@ | vim -R - ; } function maxhead() { head -n `echo $LINES - 2|bc` ; } function maxtail() { tail -n `echo $LINES - 2|bc` ; } # ---- notify ------------------------------------------------------------ function wmiintf() { col="$1" ; shift msg="$@" echo "col = '$col'" echo "msg = '$msg'" wmiir create /bar/000_ntf echo -n "$col" | wmiir write /bar/000_ntf/colors echo -n "$msg" | wmiir write /bar/000_ntf/data sleep 5 wmiir remove /bar/000_ntf } function nn() { cmd=$@ $cmd rc=$? if [ x$rc = x0 ] ; then wmiintf "#ffffff #22AA22 #00FF00" "$cmd" else wmiintf "#ffffff #AA2222 #FF0000" "$cmd" fi } # ---- other ------------------------------------------------------------ # if you use this bash function, you can do 'dpan DBD::ODBC' # and it will get the debian package if it exists function dpan () { PKG=`perl -e '$_=lc($ARGV[0]); s/::/-/g; print "lib$_-perl\n"' $1`; echo apt-get install $PKG; } # gives last time the cmdline was changed in seconds since epoc and since the process is a daemond it doesn't # change once it started getetime() { pid=$(pgrep -o $1) if [ -z "$pid" ];then echo "-1" return 1 fi let etime=$(date +%s)-$(stat -c %Y /proc/$pid/cmdline) echo $etime } alias lindent='sh /usr/src/linux/scripts/Lindent' alias rm='rm -i' #alias cp='cp -i' #alias mv='mv -i' alias ..='cd ..' # print pretty calendars #alias pcal-portrait="pcal -F 1 -m -J -p -y 0.9" #alias pcal-landscape="pcal -F 1 -m -J -l -X 70" alias pcal-portrait="pcal -F 1 -m -J -p" alias pcal-landscape="pcal -F 1 -m -J -l" # wine? alias win='wine -desktop 800x600 -depth 16' # color make ? if ( which colormake > /dev/null 2>&1 ) ; then alias cmake='colormake' #elif ( which cmake > /dev/null 2>&1 ) ; then # alias cmake='cmake' fi export LS_OPTIONS='--color=auto' eval `dircolors` alias ls='ls -F $LS_OPTIONS' alias ll='ls -F $LS_OPTIONS -l' alias grep='grep --color=auto' #if ( which clr > /dev/null 2>&1 ) ; then # alias cgrep='clr grep' #fi fi