[NCLUG] gnome-open configuration or alternative

Bob Proulx bob at proulx.com
Wed Sep 5 22:29:26 MDT 2007


S Luke Jones wrote:
> That's my point. I don't care about the windowing system. I live inside 
> a terminal.

In the beginning was the command line...

> What I'm looking for is a single command-line tool (on the Mac it's 
> called "open") that is aware of this update-alternatives-kind of 
> database of filetype:application associations, and that lets me open the 
> different sorts of file from the command line with a single command. So 
> I don't type 'gv' or 'acroread' or 'gvim' or 'epiphany -some -weird 
> -options' but simply 'open' and the tool looks up those commands and 
> exec's them appropriately.
> 
> Is there anything like that in gnome? (Or better yet, 
> windowing-system-agnostic?)

You might want to look at one of the file managers such as "midnight
commander' (aka mc) as it is independent of the desktop and runs in
the terminal.  There are an endless number of file managers and they
often include dynamic launching of applications when opening them.
You could look for them and browse the selection.

  apt-cache search file.manager

Among the high profile candidates: filerunner gentoo krusader lfm mc
nautilus rox-filer ytree.  And of course there are more.

I don't tend to use any of those myself.  When using the command line
the user usually knows what type of files things are and what they
want to do with them.  Beside I think those happy automatic functions
will often not do the right thing.  For example what should be the
default action when opening a script?  Should the default action be to
edit the script or to run the script?  If the default is to run it
then how would someone edit the script?  Since I know the action that
I want to do I would simply invoke the right action.

There are a set of general purpose wrapper tools that will detect what
is installed and then use those things.  This is the 90 degree rotated
part of your question.  These commands don't automatically know about
certain file types but they know about what commands are installed to
be invoked once you know you want to invoke them.  There is a set of
two layer wrappings to provide this configurability in two different
ways.

  sensible-editor somefile
  sensible-pager somefile
  sensible-browser http://www.example.com/

Those are scripts that respect environment variable settings (EDITOR,
VISUAL, PAGER) and wrap the underlying alternatives.

  editor somefile
  pager somefile
  www-browser http://www.example.com/

Those use the update-alternatives symlinks to invoke any of the
appropriate command such as for the editor the symlink might point to
any of vi, vim, elvis, emacs, xemacs, etc. depending upon what is
installed and available.

Bob



More information about the NCLUG mailing list