uryupinsk/alfred2-workflows — pull request #1 by CalebGrove (2014-09-29 06:02:21+00:00)
Title: Harnessing AppleScript's "activate" Command

Changed the "Run Script" script so that the nvALT window will always jump to front when called by a
search by using AppleScript's "activate" command.

The new code:

``` ruby
require 'cgi'

def osascript(script)
system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten
end

filename = File.basename("{query}",File.extname("{query}"))

osascript <<-END
tell application "nvALT"
activate
end tell
END

%x{open "nvalt://find/#{CGI.escape(filename).gsub(/\+/,'%20')}"}
```