title: Bash - ack - limit length of matched line
body: <p>Is there a way to limit the length of the line matched by ack? If ack matches, for example, a minified javascript file, the line it prints out can be very large. I still want it to show the highlighted match, but ideally with the line cut before and after the match with elipses: <code>"... stuff match stuff ..."</code>. Not seeing anything conclusive in <a href="http://betterthangrep.com/documentation/" rel="noreferrer">the ack docs</a>.</p>
  
  <p>I tried digging into it with something like</p>
  
  <pre><code>ack pattern | awk '{print substr($0,1,200) }'
  </code></pre>
  
  <p>but <code>awk</code> seems to be stripping coloring and formatting, which is undesired. Also I tried (bear with me for a second):</p>
  
  <pre><code>ack pattern | ack pattern
  </code></pre>
  
  <p>To see if I could re-ack on each line and chop it up or something, but that has the same formatting problem. Piping ack output removes the line breaks apparently?</p>
  
  <p>Edited based on comment:</p>
  
  <p>Maybe it will help to explain the main reason why I want this. I use ack.vim to search in my project. I often want to ack through my javascript files to find a word, like "cookie". We have jQuery and other minified libraries versioned in our code, so they show up in the ack results. Since those files are minified, there are very few line breaks, and it shows a gigantic line in the split window which I have to scroll past. I almost never care about that match so it's annoying to take up so much space. I could just add those minified file names to my ackrc to ignore but I'd prefer not to have to add a new file name every time we add a minified library. There is <a href="https://github.com/mileszs/ack.vim/issues/30" rel="noreferrer">an open issue</a> on the ack.vim repo about this. I want to know if it's possible to do purely through bash-fu.</p>