     if file isnt null
       filePath = path.dirname(file?.path)
 
-      switch process.platform
-        when "darwin"
-          args = "-R #{file.path}"
-        when "win32"
-          args = "/select,#{file.path}"
-        when "linux"
-
-          # Refined Linux arguments
-          if @fileManager is "nautilus"
-            args = "-w #{filePath}"
-          else if @fileManager is "dolphin"
-            args = "--select #{filePath}"
-          else
-            args = filePath
-
       # Reveal file
-      exec "#{@fileManager} #{args}"
+      shell.showItemInFolder(file.path)
       return
 
     atom.notifications.addWarning("**#{@self}**: No active file", dismissable: false)

        continue

      # Open project folder
      exec "#{@fileManager} #{project}"

  browseConfig: ->
    configPath = path.dirname(@configFile)

    if @fileManager isnt null
      # Does config folder exist?
      try
        fs.accessSync(configPath, fs.F_OK)
      catch error
        atom.notifications.addError(@self, detail: error, dismissable: true)
        return

      args = configPath

      # Open config folder
      exec "#{@fileManager} #{args}"

  getFileManager: ->
    fm = atom.config.get('browse.fileManager')

    if typeof fm isnt 'undefined'
      if @debug?
        console.log "[#{@self}] Load from config: #{fm}"
      return fm

    switch process.platform
      when "darwin"
        return "open"
      when "win32"
        return "explorer"
      when "linux"
        # There are many possible file managers on Linux, let's iterate over
        # the most popular ones
        @loopWhich (result) ->
          if typeof result isnt 'undefined'
            fm = result.trim()
            if @debug
              console.log "[browse] Saving #{fm} for future use"
            atom.config.set('browse.fileManager', fm)
            return fm

          atom.notifications.addWarning("**browse**: No supported file manager detected", dismissable: true)

  loopWhich: (callback) ->
    for fm in @linuxFileManagers

      if @debug
        console.log "[#{@self}] Trying: #{fm}"
      exec "which #{fm}", (error, stdout, stderr) ->
        if error is null
          callback stdout

# Dependencies
fs   = require 'fs'
path = require 'path'
shell = require 'shell'

{CompositeDisposable} = require 'atom'

module.exports = BrowsePackages =
  self: 'browse'
  subscriptions: null
 
  activate: ->
    # Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
    @subscriptions = new CompositeDisposable

