PDA

View Full Version : open using default program in terminal



mlissner
12th November 2006, 04:22 AM
Is there a way to use the terminal to open things using the default program?

Like, a moment ago, I did an ls of a folder, and found the pdf document I wanted. It was then that I realized I didn't remember which program opens it, forcing me to navigate to it in a gui, and doubleclick it (I think). Google isn't bringing up and results for me on this one.

...surely there must be a simple command that opens a filetype using the default program, right?

Anybody have any ideas?

Thanks. Efficiency is everything, commandline is the way.

brunson
12th November 2006, 05:47 AM
Nautilus (the desktop manager in Gnome) has several places it looks to find the program that should be used to open a file, but they're all based on MIME types. First, you use some sort of file to mimetype mapping, usually based on file extension in Linux, then you use a mapping of mimetype to application. However, there are tons of places on the filesystem that different subsystem place these mappings. If you knew where they were, or better yet, knew how to query either Nautilus or maybe gconf2 for the mapping and application association, a script would be pretty easy to write.

Unfortunately, I don't know of anything that does that. If you were willing to do a little of the up-front research to figure out a starting set of mimetype locations, I'd be happy to whip up a short script to parse them out and fire off the application, given a list of files on the command line.

mlissner
12th November 2006, 07:21 AM
Well that's a complicated answer isn't it then?

I'm tempted to start working on this project, as it seems mighty handy, but I think I may just be better off doing an apropos and trying programs until something works. If I had the time, I'd give it a go, but I haven't.

Ah well. Thanks for the reply.

brahms
12th November 2006, 12:47 PM
gnome-open /path/to/file