Skip to content

Instantly share code, notes, and snippets.

@sra448
Created November 9, 2011 16:44
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sra448/1352028 to your computer and use it in GitHub Desktop.
Save sra448/1352028 to your computer and use it in GitHub Desktop.
sublime text 2 command for tailing and greping the rails logfile
import sublime, sublime_plugin, os
class TailCommand(sublime_plugin.TextCommand):
def run(self, edit):
from datetime import datetime
filtertext = "FLO"
# open sublime console
self.view.window().run_command("show_panel", { "panel": "console", "toggle": "true" })
# show log as output
folder = self.view.window().folders()[0]
print
print datetime.now()
print ">> open " + folder + "/log/development.log:"
log = os.popen("tail " + folder + "/log/development.log -n 200 | grep " + filtertext).readlines()
if len(log) == 0:
print ">> no matches for FLO"
else:
for line in log:
print ">> " + line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment