Skip to content

Instantly share code, notes, and snippets.

@bitc
Last active December 9, 2015 16:48
Show Gist options
  • Save bitc/4299161 to your computer and use it in GitHub Desktop.
Save bitc/4299161 to your computer and use it in GitHub Desktop.
Opens a terminal window for viewing the output of a command. Useful with Vim for viewing the progress of a compilation or other external command, when run in silent mode.
#!/bin/bash
set -e
OUTPUT_PIPE=`mktemp -u`
STDOUT_SYNC=`mktemp -u`
STDERR_SYNC=`mktemp -u`
mkfifo $OUTPUT_PIPE $STDOUT_SYNC $STDERR_SYNC
exec > >(tee -a $OUTPUT_PIPE ; echo > $STDOUT_SYNC)
exec 2> >(tee -a $OUTPUT_PIPE >&2 ; echo > $STDERR_SYNC)
urxvt \
-T termview \
-geometry 200x40+30-80 \
-e cat "$OUTPUT_PIPE" \
> /dev/null 2>&1 &
RET=0
sh -c "$*" || RET=$?
exec 1>&-
exec 2>&-
cat $STDERR_SYNC > /dev/null
cat $STDOUT_SYNC > /dev/null
rm -f $OUTPUT_PIPE $STDOUT_SYNC $STDERR_SYNC
exit $RET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment