Class: GrepProfile
- Inherits:
-
ZoomProfile
- Object
- Hash
- ZoomProfile
- GrepProfile
- Defined in:
- lib/grep_profile.rb
Instance Attribute Summary
Attributes inherited from ZoomProfile
Instance Method Summary collapse
- #colors ⇒ Object
- #exe(args, pattern) ⇒ Object
-
#initialize(operator = nil, flags = [ "--color=always", "-EHIinR", "--exclude-dir=.bzr", "--exclude-dir=.git", "--exclude-dir=.svn" ].join(" ").strip, envprepend = "", append = ".") ⇒ GrepProfile
constructor
A new instance of GrepProfile.
Methods inherited from ZoomProfile
#append, #flags, from_json, #info, #operator, #prepend, #to_s
Constructor Details
#initialize(operator = nil, flags = [ "--color=always", "-EHIinR", "--exclude-dir=.bzr", "--exclude-dir=.git", "--exclude-dir=.svn" ].join(" ").strip, envprepend = "", append = ".") ⇒ GrepProfile
Returns a new instance of GrepProfile.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/grep_profile.rb', line 33 def initialize( operator = nil, flags = [ "--color=always", "-EHIinR", "--exclude-dir=.bzr", "--exclude-dir=.git", "--exclude-dir=.svn" ].join(" ").strip, envprepend = "", append = "." ) super("grep", flags, envprepend, append) @taggable = true end |
Instance Method Details
#colors ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/grep_profile.rb', line 5 def colors [ 'GREP_COLORS="', "fn=1;32:", "ln=0;37:", "ms=47;1;30:", "mc=47;1;30:", "sl=:cx=:bn=:se=", '"' ].join.strip end |
#exe(args, pattern) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/grep_profile.rb', line 17 def exe(args, pattern) # Emulate ag/ack as much as possible if (pattern.nil? || pattern.empty?) system( "#{self.to_s} #{args} #{self.append} | " \ "sed \"s|\\[K[:-]|\\[K\\n|\" | #{@pager}" ) else system( "#{self.to_s} #{args} #{pattern.shellescape} " \ "#{self.append} | sed \"s|\\[K[:-]|\\[K\\n|\" | " \ "#{@pager}" ) end end |