Open a URL highlighted from anywhere on your desktop with this quick tip for Fedora

Sometimes when i am using certain applications (especially text editors), the applications themselves do not make URLs that are written out clickable and openable in my default browser. Usually, this would result in me having to highlight the link, copy it to the clipboard, switch to my web browser, open a new tab, paste the link and go.

However, the quick hack for Fedora described in this tutorial will set up a keyboard shortcut so you can simply highlight the link text, do a keyboard shortcut, and the link will open up in your default browser.

Step 1 — Download xsel

first up we need to download a little command line utility called xsel that will let us get at the clipboard selection from a bash script. Install xsel with the command:

sudo yum install xsel

Step 2 — create the script in your user’s bin directory

If you don’t already have it, create a directory called


in the .local directory in your home directory:

mkdir ~/.local/bin

Then edit a new file in ~/.local/bin (i called mine openindefaultbrowser):

gedit ~/.local/bin/openindefaultbrowser

Now, add the following code to the openindefaultbrowser file, and save it.


xdg-open $(xsel -p)

Now, finally, make the script executable with the command:

chmod +x ~/.local/bin/openindefaultbrowser

Step 3 — bind your new script to a keyboard shortcut

Open up the keyboard preferences, and switch to the “shortcuts” tab. Click “Custom Shortcuts” from the list on the left, and then click the + button to add a new shortcut. Name the shortcut whatever you want and put the name of your script in the command field and press add.


Now, click on the shortcut, and assign an keyboard combo. (i chose super+F).

Ready to go

Your new shortcut should be ready to go. To use it, highlight (select) the text of a url, press your keyboard shortcut, and your webbrowser should open up with the link you highlighted. Note that this script is not smart, if you highlight something that is not a url, and press the shortcut, it will try to open it as it was a url 🙂


Fedora Project community


  1. Abdiel Rosario

    This is awesome!!!

  2. The script should probably go into ~/.local/bin to make selinux happy.

  3. pixecs

    A slightly updated script to handle selections without http protocol (at least this is the case on my opensuse)

    LINK=$(xsel -p)
    if [[ $LINK != http://* ]]
    xdg-open $LINK
    • nice!

      of course, another workaround to this would be just to use the command for your browser directly in the script, rather than the xdg-open one (that opens in the default app for whatever you pass it).

  4. Hy, someone with this error?

    xdg-open: unexpected argument '+x'
    Try 'xdg-open --help' for more information.

    cat openindefaultbrowser
    xdg-open $(xsel -p)
    • Rafael,

      This script works my using the currently highlighted text (aka the middle click clipboard) as the URL to pass to the browser. It seems that the last thing you highlighted before running the script was the line to change the permissions of the script (i think that is where the “+x” is coming from) if you highlight a URL, and run the script it should work as expected.

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions

%d bloggers like this: