2013-09-16

OS X: kill all Google Chrome tabs from the shell

If there are a lot of tabs open in Google Chrome, it tends to become slow. Killing tabs by hand, via the Task Manager helps, but is tedious. The following bash script (by Sindre Sorhus) lets you conveniently kill all open tabs from the shell (OS X only):
    #!/bin/bash

    ps ux | \
    grep '[C]hrome Helper --type=renderer' | \
    grep -v extension-process | \
    tr -s ' ' | \
    cut -d ' ' -f2 | \
    xargs kill

    # [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
That is, all tabs are still open, but they don’t display any content. You can reload any tab to get the content back.

I’d love Chrome to have a mode where all background tabs are stopped completely and only the frontmost tab is active. Kind of like processes are managed on iOS.

No comments: