Skip to content

Instantly share code, notes, and snippets.

@ljos
Forked from sinelaw/tailor.sh
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljos/5913d5205b492ecdcf5c to your computer and use it in GitHub Desktop.
Save ljos/5913d5205b492ecdcf5c to your computer and use it in GitHub Desktop.
#!/bin/bash -eu
LOG_FILE=$1
SB="stdbuf -i0 -oL"
shift
tput sc
$@ 2>&1 | $SB tee $LOG_FILE | $SB cut -c-$(tput cols) | $SB sed -u 's/\(.\)/\\\1/g' | $SB xargs -0 -d'\n' -iyosi -n1 bash -c 'tput rc;tput el; printf "\r%s" yosi'
EXIT_CODE=${PIPESTATUS[0]}
tput rc;tput el;printf "\r" # Delete the last printed line
exit $EXIT_CODE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment