How to return a list of all text editors via terminal

bashterminaltext-editor

Is there a way to return a list of all the installed text editors via the command line?

I think (I can't test to confirm) this answer inadvertently gives the equivalent for ubuntu:

sudo update-alternatives --config editor

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /bin/nano            40        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
  3            /usr/bin/vim.basic   30        manual mode
  4            /usr/bin/vim.tiny    10        manual mode

I gave that a try on mac, but command not found.

Best Answer

No, there's no such command or list available in the Terminal.

The command you've found for Ubuntu is part of the so called alternatives system that is found mostly in Debian-based Linux distributions. It's not available on all Linux systems, it's not available on BSD based systems and definitely not available on macOS.

Also the update-alternatives command does not necessarily list all text editors on the system (you see your own list is pretty small). It is only lists those that are registered with the alternatives system, which is not all of them. Commonly GUI-based editors are not listed here for example.

Instead of alternatives, macOS has the concept of file associations or "preferred applications". As far as I recall, this predates alternatives. Application bundles on macOS contain information about the file types that the application is willing to support. The user can choose which application is by default used to open a specific file type - this means that you can associate for example JPEG files with the photo editing software of your own choice. However, this is for GUI programs - not command line utilities as such.

An easy way to list and manipulate file associations via the command line is to use the third party utility SwiftDefaultApps. It can be installed from HomeBrew Casks using this command:

brew cask install swiftdefaultappsprefpane

After installation you'll have a command available named swda. You can run it like this to get a list of file associations:

swda getUTIs