diff --git a/Kill Process.alfredworkflow b/Kill Process.alfredworkflow index b2a3870..cadc143 100644 Binary files a/Kill Process.alfredworkflow and b/Kill Process.alfredworkflow differ diff --git a/script.rb b/script.rb index d71ce68..2f73522 100644 --- a/script.rb +++ b/script.rb @@ -13,7 +13,7 @@ # The -A flag shows all processes. The -o pid, -o %cpu, and -o comm show only the process's PID, CPU usage and path, respectively. # Grep for processes whose name contains the query. The regex isolates the name by only searching characters after the last slash in the path. # The -i flag ignores case. -processes = `ps -A -o pid -o %cpu -o comm | grep -i [^/]*#{Regexp.quote(theQuery)}[^/]*$`.split("\n") +processes = `ps -A -o pid -o %cpu -o comm | awk 'NR>1' | sort -nrk 2,2 | grep -i [^/]*#{Regexp.quote(theQuery)}[^/]*$`.split("\n") # Start the XML string that will be sent to Alfred. This just uses strings to avoid dependencies. xmlString = "\n\n" processes.each do | process | @@ -41,7 +41,7 @@ iconType = "" end # Assemble this item's XML string for Alfred. See http://www.alfredforum.com/topic/5-generating-feedback-in-workflows/ - thisXmlString = "\t + thisXmlString = "\t #{processName}#{matchedArgs.join(" ")} #{processCpu}% CPU @ #{processPath} #{iconValue} @@ -51,4 +51,4 @@ end # Finish off and echo the XML string to Alfred. xmlString += "" -puts xmlString \ No newline at end of file +puts xmlString