List the extensions installed in Safari for Mac OS X, and state whether each one is enabled

bashsafarisafari-extensionsterminal

I'd like a list, from which text can be copied.

(Not a screenshot of preferences.)

This information does not appear in any of the following:

  • Safari
  • System Profiler in Snow Leopard
  • System Information in Lion.

I wondered whether there exists an extension to list other extensions, but when I searched I could not find anything suitable.

If not a command or an extension, maybe there's an app, but again: I could not find anything suitable.

(I could instead have posted this opening question to Super User, where a command piping guru might step up, but I prefer Ask Different for the likelihood of someone knowing an extension or app.)

Background

With the extensions master switch off, the simple presence of installed extensions may cause some versions of Safari to take longer than expected to launch.

For that reason and others, it's sometimes necessary to have a comprehensive list of installed extensions, including those that are disabled.

Best Answer

It's primarily a matter of parsing the output of defaults read ~/Library/Safari/Extensions/extensions and formatting it in a user-friendly way. The result actually answers both of your questions:

defaults read ~/Library/Safari/Extensions/extensions | awk '
/Bundle Directory/ {
    split($0, t, /\"/);
    sub(".safariextension", "", t[4]);
    sub("-1", "", t[4]);
    bundle=t[4]
    e="disabled"
}
/Enabled/ {
    e="enabled";
}
/Hidden Bars/ {
    print bundle, "...", e
}' | sort --ignore-case

Creating a shell script out of it is left as an exercise to the reader.

Please note that this will most probably stop to work if Apple decides to change the format of ~/Library/Safari/Extensions/extensions