 
   scan: (regex, iterator) ->
     regex = new RegExp(regex.source, 'g')
-    command = "grep --null --perl-regexp --with-filename --line-number --recursive --regexp=\"#{regex.source}\" #{@getPath()}"
+    commands = [
+      "find \"#{@getPath()}\" -type f"
+      "grep --perl-regexp --invert-match --regexp=\"#{@ignorePathRegex()}\""
+      "xargs grep --null --perl-regexp --with-filename --line-number --recursive --regexp=\"#{regex.source}\""
+    ]
+
+    command = commands.join(" | ")
     ChildProcess.exec command, bufferLines: true, stdout: (data) ->
       for grepLine in data.split('\n') when grepLine.length
         nullCharIndex = grepLine.indexOf('\0')

    deferred

  ignorePath: (path) ->
    fs.base(path).match(/\.DS_Store/) or path.match(/(^|\/)\.git(\/|$)/)

  resolve: (filePath) ->
    filePath = fs.join(@getPath(), filePath) unless filePath[0] == '/'

    @setTabText('  ')
    @setAutoIndent(true)
    @setSoftTabs(true)
    @ignoredPathRegexes = [
      /\.DS_Store$/
      /(^|\/)\.git(\/|$)/
    ]

  getPath: ->
    @rootDirectory?.path
