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
  • 105,631
  • 46
  • 284
  • 425
Peter M
  • 47
  • 2
  • Type in terminal: libreoffice /home/locationyourfileis/file.odt. It will automatically open the document in Libreoffice. – Russo Aug 29 '17 at 09:46
  • 5
    @Russo better yet, `xdg-open` instead of `libreoffice`, so that whichever handler is installed is automatically opened. – muru Aug 29 '17 at 09:47
  • And essentially asked the same question earlier: https://askubuntu.com/questions/778154/windows-file-paths-in-ubuntu – DK Bose Aug 29 '17 at 09:47
  • 1
    I don't understand. Can't you just double click the file? What more do you need? Or just `libreoffice /path/to/file`? – terdon Aug 29 '17 at 09:51
  • 1
    @MarkKirby I would suggest to remove the mention of Windows paths from this question and the mention of "one-click opening" from the other question? That way it would match the answers better and we have no double-post. – Byte Commander Aug 29 '17 at 11:08

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
  • 193,181
  • 53
  • 473
  • 722
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,868
  • 2
  • 14
  • 22
  • You can also use ALT+F2 instead of opening a terminal if the OP wants something similar to the "Run" window of Windows. – Dan Aug 29 '17 at 10:39
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
  • 105,631
  • 46
  • 284
  • 425
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
  • 29,351
  • 10
  • 85
  • 161