GNOME Bugzilla – Bug 708533
When opening URI, allow to select file via fragment, e.g. "file:///etc#hostname"
Last modified: 2016-03-01 18:46:46 UTC
Currently, when opening an URI like "file:///etc#hostname", a window with the etc folder is shown. It would be very handy if the fragment (if present) is interpreted to mean "select the file in the resulting window". Now you may ask: Why would this be useful, when Nautilus already provides the functionality by just calling "nautilus /etc/hostname" directly? The usefulness is that the URI approach also works through gvfs-open (and xdg-open) and results in Nautilus showing the file: When calling "gvfs-open /etc/hostname", the result is that the file is opened in a text editor. When calling "gvfs-open 'file:///etc#hostname'", the file is shown in the file manager. If a file manager does not interpret the fragment, it just shows the folder without selecting the file, which is also OK and backwards-compatible. Patch upcoming.
Created attachment 255485 [details] [review] patch for interpreting fragment of file URI as file to select
If you want to open a folder and select a file in it, in a desktop agnostic way, instead of using gvfs-open or xdg-open you should use the DBus file manager interface[1]. You can call it from a terminal using dbus-send, this example will open and select your /etc/hostname file: dbus-send --print-reply --dest=org.freedesktop.FileManager1 \ /org/freedesktop/FileManager1 \ org.freedesktop.FileManager1.ShowItems \ array:string:"file:///etc/hostname" \ string:'' [1] http://www.freedesktop.org/wiki/Specifications/file-manager-interface/
Thanks for the information, but I know about the DBus interface. The nice thing about supporting this in the URI format is that it will also work e.g. when the URI is printed on the terminal or sent via mail, etc. Write this in the terminal and ctrl-click on it: file:///etc/#hostname It will currently just show /etc. With the patch it will also select the file.
Thanks for the patch Robin. I think we don't want this, a file can have a # in its file name, we don't want to use it as something different or actually have code for that. As said you can use dbus or directly nautilus (although I understand why you wouldn't) So I'm going to close it.