In linux, how can I determine the default text editor, terminal, etc?
does it vary by distro?
I accessed the list while ago programatically in a rather ugly manner and I'm sure its not the best way. The options are stored in a file called defaults.list (I think this is generally the case). The location is less general I think it in /usr/share/applications/ on my ubuntu system although it does appear elsewhere I think. I then treated it as a text file.
The resolution order is $EDITOR -> editor -> some predefined list of console editors. On Debian/Ubuntu, sensible-editor (and sensible-browser and sensible-pager) will do the lookup for you, including looking at the right environment variables. Similar variables are $PAGER, $SHELL, $BROWSER. To look up a file association, you can use xdg-open.
I don't think that the notion of default editor or terminal makes sense. For the editor, there is the convention of using $EDITOR when it is defined.
On Debian and related (e.g. Ubuntu, Mint) you have paths like /usr/bin/editor and /usr/bin/x-terminal-emulator symlinked (via symlinks in /etc/alternatives/) to some system default.
See also Dacav's answer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With