Reputation: 17545
what's a “open” command that is available on most or all linuxes?
e.g. in OS X, i can do in shell
open .
and the folder is shown in Finder (i.e. desktop) Similarly, on Windows the command is “explore”.
am asking because i want a cross-platform command in emacs.
(defun open-in-desktop ()
"Open the current file in desktop.
Works in Microsoft Windows and Mac OS X."
(interactive)
(cond
((string-equal system-type "windows-nt")
(w32-shell-execute "explore"
(replace-regexp-in-string "/" "\\" default-directory t t)))
((string-equal system-type "darwin") (shell-command "open ."))
) )
someone suggested xdg-open but am not sure if that's specific to a distro or gnome/kde only. (am not a linux user)
Upvotes: 2
Views: 418
Reputation: 88711
xdg-utils comes from freedesktop.org. The freedesktop.org project is intended to improve interoperability between the various different desktop environments available on Linux. It's as close as you'll get to reliable method for doing this on Linux therefore.
Upvotes: 8
Reputation: 65620
xdg-open points towards the user's preferred browsing application, so would work in general.
Upvotes: 3