Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@squarism
Created February 10, 2011 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squarism/821247 to your computer and use it in GitHub Desktop.
Save squarism/821247 to your computer and use it in GitHub Desktop.
A watchr one-liner shell script, perfect for single .rb projects
#!/usr/bin/env bash
# wtchr shell script - @squarism
# INSTALL
# gem install watchr
# cp wtchr ~/bin
# chmod u+x ~/bin/wtchr
# Run with: wtchr foo.rb
##################
# Main, as it were
# the file passed in as argument 1
FILE=$1
# horrifying formatting for bash and gist
watchr -e "system('clear'); \
puts 'Watchr is watching ${FILE}. O_o (wtchr)'; \
puts '-' * 52; \
watch('${FILE}') \
{ system('clear'); \
p=\`pwd\`.strip; \
cmd = 'ruby ' << p << '/${FILE}'; \
o = \`#{cmd}\`; \
puts o }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment