beforeRunningCommand nop bundleUUID 5C3E29B9-B473-457E-A850-9499F1FD783C command #!/usr/bin/env ruby require 'find' %w[web_preview exit_codes dialog textmate].each { |m| require "#{ENV['TM_SUPPORT_PATH']}/lib/#{m}" } dir = ENV['TM_PROJECT_DIRECTORY'] || ENV['TM_DIRECTORY'] query = ENV['TM_SELECTED_TEXT'] unless query query = Dialog.request_string( :prompt => "Enter query string", :default => ENV['TM_CURRENT_WORD'], :button1 => "Search", :button2 => "Cancel") unless query TextMate.exit_discard end end filter = Regexp.new(ENV['TM_QS_FILTER']) if ENV['TM_QS_FILTER'] search_in = TextMate.selected_files search_in = [ENV['TM_FILEPATH']] if search_in.nil? || search_in.empty? $stdout.sync = true html_header 'Quick Search Result', "Search for: #{query}" puts "<ol>" count = 0 stime = Time.now Find.find(*search_in) do |f| short_f = f[/^#{dir}(.+)$/, 1] Find.prune if f =~ /(svn|CVS|jpg|gif|swf|ico|png)$/ || f=~ filter `grep -n '#{query}' #{e_sh f} /dev/null`.each do |found| next unless found =~ /:(\d+):(.+)$/ line, code = $~.captures print '<li>' print "<a href=\"txmt:\/\/open?line=%d&url=file:\/\/%s\">%s:%d</a>" % [line.to_i, e_url(f), short_f, line.to_i] print "<div style=\"font-size: 85%; margin: 3px 30px;\">#{code}</div>" puts '</li>' count += 1 end end puts "</ol>" etime = Time.now if count == 0 puts "Nothing found." else puts "<div style=\"margin: 10px\">Found #{count} occurrences. (#{etime - stime} sec)</div>" end html_footer input none keyEquivalent ^F name Quick Search output showAsHTML uuid D3A59EE8-89D8-4BF2-9D05-3B42470C8601