1

In Windows I have e.g. the following path: R:\Documents\Common\User\textual.doc. I copy this path and execute it through pasting it into »Run« or Windows Explorer. It automatically opens a document in Libreoffice.

Can anybody suggest a simple and (after some one-time typing) ONE-CLICK solution to do the same in Ubuntu?

Byte Commander
  • 110,243
Peter M
  • 47

4 Answers4

4

GNOME Shell already does this. GNOME Shell's run menu, opened using AltF2, opens paths to files which are not executable using the appropriate handler application. I tested with a video file (/usr/share/example-content/Ubuntu_Free_Culture_Showcase/Jenyfa Duncan - Australia.ogg) and an ODT file (~/foo.odt).

With Unity, the AltF2 run menu doesn't do this, but you can use xdg-open as noted elsewhere. To minimize typing, maybe create a command called o that links to xdg-open:

sudo ln -s /usr/bin/xdg-open /usr/local/bin/o

Then: AltF2, o /path/to/some/file, Enter.

muru
  • 207,228
3

You can type in terminal:

libreoffice /home/locationyourfileis/file.odt

It will automatically open the document in Libreoffice.

Or even better as suggested by muru:

xdg-open /home/locationyourfileis/file.odt

Which will open the appropriate installed handler automatically.

Russo
  • 1,908
3

You can get a simple dialogue window that prompts you for a path to enter and then opens it with the appropriate application using xdg-open when you click "Ok".

This command uses zenity (normally preinstalled) for the dialogue window and xsel (you might have to install it using sudo apt install xsel first) to already insert your current clipboard content into the entry field as default value - that means you can even save the keystrokes to paste!

openpath="$(zenity --entry --title "Open file" --text "Enter a file path to open with the appropriate application:" --entry-text "$(xsel -b)")" && xdg-open "$openpath"

zenity dialogue

This command can be run from a terminal, but it is even more useful as a keyboard shortcut. You can go to System Settings > Keyboard > Shortcuts > Custom Shortcuts and assign it to a custom shortcut, like e.g. Super+R. Note however that it must run in a Bash-compatible shell, sou you have to wrap it in bash -c '...' to use it as shortcut:

bash -c 'openpath="$(zenity --entry --title "Open file" --text "Enter a file path to open with the appropriate application:" --entry-text "$(xsel -b)")" && xdg-open "$openpath"'
Byte Commander
  • 110,243
2

While the other answers provide different ways how to simulate »Windows Run« behaviour, I accidentally found a way how to simulate »Windows Explorer« behaviour.

Within Nautilus

  • Open Nautilus and press Ctrl+L. This shortcut will switch Nautilus to show the Location bar instead of Breadcrumbs.

  • Paste your path in the Location bar and press Enter two times. The first Enter will open the location directory and will highlight (select) the target file. The second one will open the file.

  • If you want to set the Location Bar in Nautilus as default check this answer: Switch from path bar to location bar permanently in Nautilus.

Within Nemo

  • The approach and the shortcut (Ctrl+L) are exactly the same as above.

  • Nemo will remember your choice and you don't need to switch its default behaviour.

Demo

enter image description here

pa4080
  • 30,621