view .bash_aliases @ 66:594349918d47

* tr13 -> rt13
author huston@80426f53-59d1-405d-934b-f07cd76f4a1a
date Tue, 10 Jul 2012 23:01:42 +0000
parents 89650cf05c4c
children 0110dfac917e
line wrap: on
line source

# $Id$

# Aliases are read from this file; no real reason to separate them out except
# for readability.

# Some settings which are architecture dependent
case `uname` in
  Darwin)
    # DARWIN is used for the SSHFS mounts below
    DARWIN="yes"

    # The 'stat' and 'date' commands are here since the syntax of the commands
    # is different between Linux and Mac OS X.  If this is run elsewhere, the
    # eval will be false and the test not done below, so it's safe to not
    # bother checking for zero-length variables on the test - it just won't
    # run the svn status, so you won't be prompted if there's newer files
    # available in your repository.  These are safe to export since they're
    # the commands to be evaulated, not the output - you're storing how to get
    # the answer, not the answer itself.

    # Also note, the full paths are stored since GNU coreutils might be
    # installed; while that would tend to make things "easier" since the GNU
    # one is the same as the Linux ones below, it can't be guaranteed.
    # Instead of checking for the presence of /opt/local/bin/ls (or gls) it's
    # easier to point directly to the one you know *is* installed.

    DFSTAT="/usr/bin/stat -f %m -t %s $HOME/.dotfilets"
    MDATE="/bin/date -v -1m +%s"
    TDSTAT="/usr/bin/stat -f %m -t %s $HOME/.todo"
    HDATE="/bin/date -v -1H +%s"

    alias ls='/bin/ls -FG'

    VNCVIEWER="open vnc://"
    ;;

  Linux)
    # See above for a description of these four
    DFSTAT="/usr/bin/stat -c %Y $HOME/.dotfilets"
    MDATE="/bin/date -d \"1 month ago\" +%s"
    TDSTAT="/usr/bin/stat -c %Y $HOME/.todo"
    HDATE="/bin/date -d \"1 hour ago\" +%s"

    alias ls='/bin/ls --color=auto -F'

    VNCVIEWER="vncviewer Shared=1 Fullcolor=1 "
    ;;
esac

# Export some of those above for the benefit of future shells
export DFSTAT MDATE TDSTAT HDATE

# SSH aliases
alias 13='ssh cses13'
alias dh='ssh srhuston.net'
alias j='ssh joshua.srhuston.net'
alias keys='ssh-add $HOME/.ssh/*.pvt'
alias r='ssh -l root'
alias r13='ssh -t cses13 screen -raAx'
alias rj='ssh -t joshua.srhuston.net screen -raAx'
alias rx='ssh -t xanadu.astro.princeton.edu screen -raAx'
alias roc='ssh zenoss@rocinante'
alias s=ssh
t() {
  T_HOST=xanadu.astro.princeton.edu
  if [ -n "$2" ] ; then
    T_HOST=$2
  fi
  ssh -t $T_HOST "ssh $1"
}
alias t13='t cses13'
alias rt13='t "-t cses13 screen -raAx"'
alias x='ssh xanadu.astro.princeton.edu'

export CLUSTERLIST="adroit artemis della hecate oldhecate orbital sesame tigressdata"
cdsh() { 
  for H in $CLUSTERLIST ; do 
    echo $H": "
    ssh $H $@
  done
}

# Remote desktop/VNC
eval "alias xvnc='ssh -L9910:localhost:5901 -f joshua.srhuston.net \"sleep 5\"; ${VNCVIEWER}localhost:9910 &'"
eval "alias xanadu='ssh -L9920:localhost:5900 -f xanadu.astro.princeton.edu \"sleep 300\"; ${VNCVIEWER}localhost:9920 &'"
eval "alias milton='ssh -L9930:milton:5900 -f joshua.srhuston.net \"/sbin/ether-wake 00:17:f2:01:d2:3c ; sleep 30\"; sleep 10; ${VNCVIEWER}localhost:9930 &'"
eval "alias gala='ssh -L9940:gala:5900 -f joshua.srhuston.net \"/sbin/ether-wake 00:14:51:0d:94:e4 ; sleep 30\"; sleep 10; ${VNCVIEWER}localhost:9940 &'"
alias start-vnc='vncserver -geometry 1600x1178 -depth 24 -nohttpd'

# Programs
alias atari='atari800 -height 800 -width 600'
alias base64='openssl enc -a'
alias bsr='bigscreen -raAx'
alias irssi-test='irssi --home=$HOME/irssi-test/'
alias pine='alpine'
alias ret='screen -raAx'
alias rot13="tr 'a-zA-Z' 'n-za-mN-ZA-M'"
alias stendhal="java -jar $HOME/Installs/stendhal/stendhal-*.jar"
alias vi='vim'
alias tops='unset STY; screen -c .screenrc.pbstops -S pbstop'

# SSHFS mounts
# The $DARWIN check fills in a nice volname if this is a Mac
alias junkpile="sshfs -oreconnect${DARWIN:+,volname=Junkpile} srhuston.net:junkpile $HOME/junkpile"
alias sj="sshfs -oreconnect${DARWIN:+,volname=Joshua} joshua.srhuston.net: $HOME/joshua"
alias sdh="sshfs -oreconnect${DARWIN:+,volname=srhuston.net} srhuston.net: $HOME/srhuston.net"
alias ssy="sshfs -oreconnect${DARWIN:+,volname=Syrinx} syrinx.astro.princeton.edu: $HOME/syrinx"
alias sx="sshfs -oreconnect${DARWIN:+,volname=Xanadu} xanadu.astro.princeton.edu: $HOME/xanadu"

# LDAP/host tools
alias ldm="ldapmodify -Z -x -W -c -D 'cn=DrAdmin,dc=astro,dc=princeton,dc=edu'"
alias ldsloop='while true; do read; clear; lds "$REPLY"; done'
alias hostmaster='ssh -x -a huston@arizona.princeton.edu /usr/oit/bin/hostinfo'

# Other
alias condor_check="ls -lat /u/condor/hosts/*/log/MasterLog"
alias slurp="wget -r -l1 -np -nd -A.mp3"

# Other Functions

lds() { 
  QUERY="$1"
  shift
  ldapsearch -LLL -x "($QUERY)" $@
}

update_toodledo() {
  case `hostname -s` in
   xanadu|syrinx)
     TOODLEDO_CMDS="toodledo tasks @Work; toodledo tasks @Anywhere"
     ;;

   milton|joshua)
     TOODLEDO_CMDS="toodledo tasks @Home; toodledo tasks @Anywhere"
     ;;

   rapture)
     TOODLEDO_CMDS="toodledo tasks @Anywhere"
     ;;
  esac

  [[ -e $HOME/.todo.$$ ]] && return

  eval $TOODLEDO_CMDS | egrep '^<[0-9]+>' | ( 
    set -f
    while read TASK ; do

      if echo $TASK | grep -v 'startdate\[' ; then
        continue
      fi

      TODAY=`date "+%Y/%m/%d"`
      STARTDATE=`echo $TASK | sed 's/.*startdate\[\([^ [.].]]*\)\].*/\1/'`
      [[ "$TODAY" > "$STARTDATE" || "$TODAY" == "$STARTDATE" ]] && echo $TASK

      done 
  ) >> $HOME/.todo.$$

  [[ $? -eq 255 ]] && { 
    # Update failed; clean up & don't do it again.
    rm $HOME/.todo.$$
    touch $HOME/.todo
    return
  }
  echo "To-do list as of `date`" > $HOME/.todo
  echo "---------------------------------------------" >> $HOME/.todo
  egrep '#\[[0-9]+/[0-9]+/[0-9]+' $HOME/.todo.$$| sort -k 6.3 >> $HOME/.todo
  egrep -v '(#\[[0-9]+/[0-9]+/[0-9]+|status\[(Delegated|Waiting|Hold|Postponed|Someday|Canceled|Reference)\])' $HOME/.todo.$$ >> $HOME/.todo
  rm $HOME/.todo.$$
}

TOhtml() {
  OUTDIR=`mktemp -d TOHTML.XXXXXX`
  for F in `svn ls -R` ; do 
    if [ -d $F ] ; then 
      continue
    fi

    # Files to ignore from the list
    case $F in
      .vim/plugin/gnupg.vim | \
      .vim/syntax/syslog.vim| \
      .vim/syntax/yum.vim   \
      )
        continue
        ;;
      *)
        ;;
    esac

    OUT=`echo $F | sed -e 's/^\.//' -e 's,.*/,,'`
    vim -e +TOhtml "+w ${OUTDIR}/${OUT}.html" +qa\! $F
  done
  echo Files stored in $OUTDIR
}

# vim: set filetype=sh :