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.

Using gnome terminal (Ubuntu 10.10), is there a way to execute the default application associated to a file type, only by typing its name, as it is possible with Windows ?

For example, say I create a mime type associated to every file with the pattern *.abc. Lets say I associate this file type to application 'my_app'.

If I have file 'my_file.abc' in current folder, what I want is that when I enter only 'my_file.abc' at the prompt, it executes 'my_app' feeding it with 'my_file.abc' as first argument. (assuming of course 'my_app' is in the path)

I appreciate this behaviour in Windows, wondering if Linux/Gnome could do that too. Thanks

share|improve this question
    
You might have better luck on askubuntu –  hbdgaf Dec 10 '10 at 16:21
    
Well, yes, actually, I didn't know askubuntu until now. Is there a way to "switch" this post to askubuntu ? –  kebs Dec 10 '10 at 20:55
add comment

3 Answers

up vote 2 down vote accepted

You could use the binfmt_misc facility for something similar, but you're probably better off just passing it to xdg-open.

share|improve this answer
    
Very interesting, I'll investigate this tool, thank you. –  kebs Dec 10 '10 at 20:55
add comment

I don't know of any unix shell that allows you to execute any file in this way.

On Debian or Ubuntu, see myfile or edit myfile opens a file in the application that's associated to the file type through the mailcap mechanism. The command is from the mime-support package, which I think is installed by default on both Debian and Ubuntu (and anyway it's in many packages' dependencies, so it's probably installed already).

On many systems, you can use xdg-open myfile from the xdg-utils suite. This opens the file in the application that's associated to the file type through the Freedesktop mechanism. The Ubuntu package is xdg-utils, also probably installed already.

share|improve this answer
    
Yeah, xdg-open works fine, I was only trying to see if what was possible on Windows could be transposed to Linux ;-) I struggled a bit with binfmt_misc, but couldn't get it to work in a seimple way, i.e.: echo ':txt_file:E:*.txt:::/usr/bin/gedit::' > /proc/sys/fs/binfmt_misc/register but this doesn't work on my machine... I guess it wasn't designed to do such things in the beginning. –  kebs Dec 14 '10 at 13:46
    
And by the way, do you guys know if there is any difference between "see" and "xdg-open" ? They both seem to use the system's mime database... –  kebs Dec 14 '10 at 13:51
    
@kebs: see uses exactly the system's MIME database (including ~/.mailcap. I think xdg-open uses a completely different FreeDesktop-specified database, but Debian and Ubuntu packages tend to populate both these databases. –  Gilles Dec 14 '10 at 22:15
add comment

You could use gnome-open for that. Works pretty well for me.

share|improve this answer
add comment

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.