Last active
December 9, 2015 16:48
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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