Ubuntu – Open file by mouse click on file path in terminal

command linemouse

Is there a terminal, or a tool that allows to have the following feature when working in a terminal? I execute a command like find . -name "*.cpp, or compilation of source code that produces some warning or failing output in files. When the command execution is over I can click on file paths and open them in some program, like editor, viewer. I think in some cases it could improve productivity very well.

The only feature similar to this I saw in guake terminal, called "Quick Open".

Best Answer

Not a click-only solution, but a select / hit a keystroke / click solution, which on the other hand allows to open any selection (also outside of a terminal) and in different editors (and to do lots of other neat things);

  • Download Colinker from here;

  • Open Terminal by hitting CTRL+ALT+T;

  • Install Colinker's dependencies by running sudo apt-get update && sudo apt-get install openjdk-8-jre xclip;

  • Install Colinker by running unzip ~/Downloads/Colinker-1.0.1.zip && sudo mv ~/Downloads/Colinker-1.0.1 /opt;

  • Edit Colinker's configuration file by running nano /opt/Colinker/config.xml;

    Here's a sample configuration file to open a selection in Gedit:

<Configuration>
    <Env>
        <timerDelay>4000</timerDelay>
        <defaultBrowser>firefox</defaultBrowser>
    </Env>
    <popupMenu>
        <item name="Open with Gedit">
            <program javaEscapeSelectedText="true">
                <location>gedit</location>
                <arg>__SELECTEDTEXT__</arg>
            </program>
        </item>
    </popupMenu>
</Configuration>
  • Bind the execution of Colinker to a keystroke by adding a custom shortcut running the following command:
bash -c "cd /opt/Colinker; java -jar Colinker.jar \"$(xclip -o)\""

That's it! Final result:

Opening Terminal with CTRL+ALT+T

screenshot1

Running find ~/tmp -type f -iname '*.txt'

screenshot2

Selecting "/home/user/tmp/file.txt"

screenshot3

Hitting the keystroke

screenshot4

Clicking "Open with Gedit"

screenshot5