Open file by mouse click on file path in terminal

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


I personally use keybindings to open file directly from my terminal.

For instance, on my .zshrc :

## Open file on Vscode
# Press f1 --> last selection is a relative path 
bindkey -s '^[OP' 'code \"$(pwd)/$(xclip -o)\"\n'
# Press f2 --> last selection is an absolute path
bindkey -s '^[OQ' 'code \"$(xclip -o)\"\n'

It needs xclip : sudo apt-get install xclip

^[OP is F1 's keycode, using cat -v to find it out.

\n is needed at the end of the micro-script to auto-launch it.

Do not forget to source ~/.zshrc or to relaunch your terminal for changes to take effect.