14

I have some text files that contains some links/url. I would like to open the link/url in firefox or chrome when I click (left mouse click) the link. Is that possible?

So far I have tried to add a plugin by copying the files in /usr/share/gedit/plugins/ but in the plugin preference in gedit no new plugin shows.

andrew.46
  • 37,085
  • 25
  • 149
  • 228
Sheikh Hridoy
  • 141
  • 1
  • 5

2 Answers2

9

This can be done with the nice gedit plugin open-uri-context-menu. I have tested this plugin on the three supported LTS releases:

  1. Xenial Xerus LTS (gedit 3.18.3)
  2. Trusty Tahr LTS (gedit 3.10.4)
  3. Precise Pangolin LTS (gedit 3.4.1)

Installation instructions are slightly different for each LTS release as a different version of the plugin is required for each. Select the appropriate version for your setup from the three given below:

1. Installation: Xenial Xerus

Xenial ships with gedit 3.18.3 and to install Version 3 of the plugin download and install as follows:

mkdir ~/Desktop/open_uri && cd ~/Desktop/open_uri
wget https://github.com/jpfleury/open-uri-context-menu/archive/master.zip
mkdir -pv ~/.local/share/gedit/plugins/
unzip -j master.zip 'open-uri-context-menu-master/open-uri*' -d ~/.local/share/gedit/plugins/

2. Installation: Trusty Tahr

Trusty ships with gedit 3.10.4 and to install Version 2 of the plugin download and install as follows:

mkdir ~/Desktop/open_uri && cd ~/Desktop/open_uri
wget https://github.com/jpfleury/open-uri-context-menu/archive/v2.zip
mkdir -pv ~/.local/share/gedit/plugins/
unzip -j v2.zip 'open-uri-context-menu-2/open-uri*' -d ~/.local/share/gedit/plugins/

3. Installation: Precise Pangolin

Precise ships with gedit 3.4.1 and to install Version 1 of the plugin download and install as follows:

mkdir ~/Desktop/open_uri && cd ~/Desktop/open_uri
wget https://github.com/jpfleury/open-uri-context-menu/archive/v1.zip
mkdir -pv ~/.local/share/gedit/plugins/
unzip -j v1.zip 'open-uri-context-menu-1/open-uri*' -d ~/.local/share/gedit/plugins/

4. Setup for Xenial, Trusty and Precise:

Then on any of the LTS releases open gedit and navigate to the 'Plugins' screen by following this trail:

 Edit > Preferences > Plugins

and then activate the plugin by ensuring there is a 'tick' or 'check' mark next to the plugin description as seen in the screenshot below:

enter image description here

Now when you right click on a link (admittedly not left click as you specified) within a document opened with gedit you will see the following options:

enter image description here

The two plugin options seen here are:

  1. Browse to: Open the link in an external browser such as Firefox
  2. Open: Open the contents of the link within another gedit window

Works nicely on each of my Xenial, Trusty and Precise systems and should on yours as well...

References:

andrew.46
  • 37,085
  • 25
  • 149
  • 228
  • While this is clearly the answer in this specific situation, you could also do something like this using a macro written in AutoKey https://github.com/autokey/autokey. This requires more effort, but would also work with some other editor or program which did not have such a capability or plug-in. – Joe Aug 19 '16 at 06:38
0

Modern versions* of gedit have the appropriate plugin built-in. Simply go to ☰ → Preferences → Plugins and enable "Open Links".

You can then right-click any link and a new context menu entry "Open Link" will be at the very top.

screenshot highlighting the described plugin in the list

*It was added in gedit 42, maybe a bit earlier.

Jan Pokorný
  • 221
  • 2
  • 5
  • I don't have the "Open Links" plugin in Ubuntu 20.04. – user68186 May 12 '22 at 16:27
  • @user68186 Looks like it was added in Debian 12 (bookworm), compare (libopenlinks.so): https://packages.debian.org/bookworm/i386/gedit/filelist vs https://packages.debian.org/bullseye/i386/gedit/filelist -- I'm not sure which Ubuntu added it, but I'm on PopOS 22.04 and have it. – Jan Pokorný May 13 '22 at 12:43