How to open a file or folder from Terminal with mouse

5,645

Solution 1

Gnome-terminal doesn't do this, as you are aware; unlike Nautilus, it doesn't have those sorts of extensions like open-terminal here. This is probably an undesirable feature anyway; URL recognition can be annoying as it is, but can you imagine doing a find and having everything clickable?

For your pwd example,

nautilus `pwd`

works, (but then so does nautilus .) For this task, I have a bash alias:

alias n="nautilus ."

so that whenever I type n, it opens nautilus wherever I am.

Otherwise, the format:

nautilus `<insert command that prints a directory here>` 

works, but doesn't get you the feature you're looking for.

A workaround would be:

  1. highlight the path with the mouse (which stores it in the buffer)
  2. type nautilus<space> at the prompt
  3. middle-click somewhere in the terminal (which pastes the buffer to the end of the prompt).

Solution 2

gnome-terminal creates a link when it detects a url in the terminal output. I don't think it has the ability to recognize paths the same way and I don't know of any terminal emulators that do either. You'd probably have to make a patch for gnome-terminal to make that happen.

Share:
5,645

Related videos on Youtube

vhbsouza
Author by

vhbsouza

Updated on September 18, 2022

Comments

  • vhbsouza
    vhbsouza over 1 year

    I'd like to know if there is a way to open a file or a folder from terminal using the mouse?

    When I wrote a URL LINK in terminal, it's allows me to open that link on my default browser. So I'd like to do the same with my files and folders.

    I know that there is a way via cli using gnome-open or xdg-open, but I'd like a solution that uses the mouse by clicking on the path or the url.

    Eg. when I write "pwd" the path allows me to click and open with Nautilus

    It's the inverse of what "nautilus-open-terminal" does.

    • Uri Herrera
      Uri Herrera almost 13 years
      when i want to open a file in gedit i simply type, gedit path_to_the_the file or if i'm already in the folder i type gedit name_of_the_file
    • matanster
      matanster almost 10 years
      The comment from @elmicha is the right answer so it seems (works for me). Requires holding down CTRL while clicking the mouse over the hyperlink though, unless you fiddle the terminal configuration as per askubuntu.com/questions/174596/…
    • krookedking
      krookedking about 9 years
      Being used to iTerm2 in OS X, I definitely miss this feature.
    • alexanderadam
      alexanderadam over 2 years
      There is also an official feature request regarding this: gitlab.gnome.org/GNOME/gnome-terminal/-/issues/7054
  • elmicha
    elmicha almost 13 years
    Besides that, file URIs like file:///etc/passwd work in gnome-terminal and in konsole.
  • vhbsouza
    vhbsouza almost 13 years
    I already know that using "file://" gnome-terminal will allow, but there is a way to put this URI Scheme and don't show them?