Created
December 17, 2016 23:38
-
-
Save pjrt/96471d03de258efab41baeba6f43fa92 to your computer and use it in GitHub Desktop.
Quickfix SBT
This file contains hidden or 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
#!/usr/bin/env bash | |
############ | |
# QuickSBT # | |
############ | |
# Launch SBT with support for generating /tmp/sbt.quickfix file for Vim | |
# http://github.com/aloiscochard / https://gist.github.com/4698501 | |
gitroot=$(git rev-parse --show-toplevel);\ | |
quickfix=${gitroot}/.git/sbt.quickfix;\ | |
sbt $@ | tee \ | |
>(while read line;\ | |
do \ | |
if echo "$line" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | grep '\[error\]' >> ${quickfix}.raw;\ | |
then sed -n '/\^/{x;d;};1h;1!{x;p;};${x;p;}' ${quickfix}.raw > $quickfix; fi;\ | |
done > /dev/null\ | |
) \ | |
>(clean=false; while read line; \ | |
do \ | |
if echo "$line" | grep '^> .*$'; then clean=true; fi;\ | |
if $clean; then rm ${quickfix}.raw 2> /dev/null; rm $quickfix 2> /dev/null; clean=false; fi;\ | |
if echo "$line" | grep 'Waiting for source changes'; then clean=true; fi \ | |
done > /dev/null\ | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment