citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

chat (884B)


      1 #!/usr/bin/env bash
      2 
      3 HOST=$(hostname)
      4 CHATFILE=/home/jb55/famchat
      5 
      6 if [ "$HOST" = "monad" ]; then
      7   USER=will
      8 elif [ "$HOST" = "quiver" ]; then
      9   USER=will
     10 else
     11   USER=vanessa
     12 fi
     13 
     14 update () {
     15   scp jb55@192.168.86.26:bin/chat "$HOME/bin/chat"
     16 }
     17 
     18 if [ "$USER" = "vanessa" ]; then
     19   update
     20 fi
     21 
     22 out () {
     23   if [ "$HOST" = "monad" ]; then
     24     cat >> "$CHATFILE" && tail -n100 "$CHATFILE"
     25   elif [ "$HOST" = "quiver" ]; then
     26     ssh 172.24.242.111 "cat >> $CHATFILE && tail -n100 $CHATFILE"
     27   else
     28     ssh jb55@192.168.86.26 "cat >> $CHATFILE && tail -n100 $CHATFILE"
     29   fi
     30 }
     31 
     32 show () {
     33   if [ "$HOST" = "monad" ]; then
     34     tail -n100 "$CHATFILE"
     35   elif [ "$HOST" = "quiver" ]; then
     36     ssh 172.24.242.111 "tail -n100 $CHATFILE"
     37   else
     38     ssh jb55@192.168.86.26 "tail -n100 $CHATFILE"
     39   fi
     40 }
     41 
     42 if [ -n "$1" ]; then
     43   printf "$(date +'%F %R') | %s\n%s\n\n" "$USER" "$*" | out
     44 else
     45   show
     46 fi
     47