#!/bin/sh
#
# logall - prepend logall to a command and its stdout and stderr will be
# timestamped and written to a textfile in $HOME/tmp.
#
# dependencies: moreutils | expect-dev

if [ "$1" = "" ]; then
  echo "logall: Need a command to run" >&2
  exit 1
fi
filename=$(date +"${HOME}"/tmp/"$(basename "$1")"_%F_%H:%M:%S.txt)
echo "running $@ at $(date +%F\ %H:%M:%S)\n" >>"${filename}"
unbuffer $@ | ts 2>&1 | tee -a "${filename}"
echo "" >>"${filename}"
