Black lives matter
Portrait Dr. Axel Rauschmayer
Dr. Axel Rauschmayer
Homepage | Twitter
Cover of book “JavaScript for impatient programmers”
Book, exercises, quizzes
(free to read online)
Cover of book “Deep JavaScript”
Book (50% free online)
Cover of book “Tackling TypeScript”
Book (first part free online)
Logo of newsletter “ news”
Newsletter (free)

OS X: kill all Google Chrome tabs from the shell

[2013-09-16] browser, chrome, mac
(Ad, please don’t block)

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):


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

    # [C] explained:
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.