I have the following ruby script, foo, that I'm watching with fswatch:

#!/usr/bin/env ruby

puts "hello world!"

on the command line the output looks like:

➜  ~/w/s/g/m/todo master ✗ fswatch bin/* | xargs -I {} bundle exec {}
hello world!

Which seems all good, and as expected, I'm wondering, how would I tell fswatch to clear the screen before running the the bundle exec? Or write some sort of bash script to achieve the same goal or watching my files and running my commands but clearing the screen before-hand?


Recently had to figure this out myself. Try: fswatch bin/* | xargs -I {} sh -c 'clear && bundle exec {}'

Edit: Completely clearing the scrollback buffer will depend upon the actual terminal emulator program used. As an example, on macOS you could do one of the following:

  • that almost clears it. it keeps the past stuff in the terminal, but aligns the new content at the top of the page and puts a big empty block above it. How do you clear it completely so u dont get lost if you accidentally scroll too far up to the top? – faceyspacey.com Jan 20 '17 at 15:05
  • @faceyspacey.com please see edit – dev Jan 20 '17 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.