hi all,
i want to associate some files with some programs like we do in windows platform.
for example on the shell prompt if i type a file name(i am in that directory) i want it to be opened by gvim editor. how can i do that?

Hey there,

I don't know that there's any built-in way to do it, since, when you type the name of a file on the command line (an executable shell script, for instance), if you typed:


the shell would assume that you wanted to execute the script and would have no way of knowing that, this time, you wanted to edit it.

Probably, a really simple way to do it would be to write your own wrapper to do edits in gvim, etc (assuming no GUI, where you could just do associations exactly like windows) - this script would assume just one argument, but should be good enough to get started.


# edit.sh

case $@ in
   *.pl) gvim $1;;
   *.sh) vi $1;;

./edit.sh script.pl

or something of that sort.
If there is a builtin way in the shell to derive intention without outside influence, clue me in. That would be cool :)

Best wishes,


binfmt_misc is news to me. Very cool :) I wonder what the implications of not wanting to use it would be. At this point, just don't mount the pseudo filesystem. I have a feeling there will always at least be 10 or Unix/Linux distro's that will give you the option of allowing the OS to implicitly determine what you want to do with your files.

Good stuff. Thanks for the links!

, Mike