Skip to content

Instantly share code, notes, and snippets.

@pjrt
Created December 17, 2016 23:38
Show Gist options
  • Save pjrt/96471d03de258efab41baeba6f43fa92 to your computer and use it in GitHub Desktop.
Save pjrt/96471d03de258efab41baeba6f43fa92 to your computer and use it in GitHub Desktop.
Quickfix SBT
#!/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