Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

MacOS has a neat open command: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/open.1.html

Does GNU/Linux have a similar command?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Yes, Linux is configurable, as Slowki says. However, that means that the answer is Yes.. Linux is configurable so it has at least five commands that are equivalent to this. Did you think that Linux developers would ignore such an idea? ☺

  • GNOME used to have gnome-open.
  • GNOME now has gvfs-open.
  • KDE has kde-open.
  • XFCE has exo-open, which uses the desktop's preferred applications settings.
  • The FreeDesktop people have xdg-open, which will try to invoke one of the preceding four, or attempt to perform something appropriate itself.

Of course, these are all predicated upon having a "desktop environment" of some sort. They all consult their various desktop environments' "settings" databases. (There's a rough agreement across several desktop environments about the settings databases.) But then so is your question, as MacOS 10's open is also predicated upon a desktop.

However, that doesn't mean that the TUI world is lacking similar tools. The run-mailcap command operates from the mailcap and mime.types settings files, for example. However, the TUI world is a subject better treated by a separate question.

Further reading

share|improve this answer

No, Linux is too configurable for that, on OSX you start off with Safari, the OSX File Manager, etc, but on my laptop right now I don't even have graphical and I work purely in TTY, to get an open command on Linux to work it would need to be told how to handle every file, which at that point I might as well just make my own.

#!/bin/bash
if [ -d $1 ]; then #Check if $1 is a directory
    nautilus $1 #To be honest pcmanf is way better
fi
if [ -f $1 ]; then #Check if $1 is a file
    if [ $1 == *.txt ]; then #Is the extension .txt?
        gedit $1
    fi
fi

I personally prefer to alias the file extensions, so I can just type to path to the file and it will open it, decompress it, compile it, etc, it's one of the better features of ZSH, I recommend you try it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.