14

Double clicking on a word in gnome terminal selects the whole word. Unfortunately, this selection doesn't include colons such that URLs aren't completely selected, e.g. with

http://foo.example.org/

only

//foo.example.org/

is selected.

How do I configure this selection behavior such that complete URLs are selected?

See also:

1 Answer 1

21

How much is selected on double click can be configured via adding additional character classes to the default set. That means that adding a colon and other special characters that may show up in URLs leads to double click also selecting complete URLs.

This can be configured via the gnome config database. For that one has to get the id of the gnome shell profile. To get the default one:

puuid=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d "'")

Adding some URL related characters:

gsettings set \
org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$puuid/ \
    word-char-exceptions '@ms "-=&#:/.?@+~_%;"'

Note that:

  • @ms denotes the maybe-string gvariant type
  • the character class syntax matches the regex one, i.e. a-z specifies a range, where -az specified the literal 3 characters. Thus, I have explicitly put the - in the first position

History: In classic Gnome Terminal versions, the profile preference dialog contained a field for configuring those additional characters. With Gnome 3, UI experts have removed this option from the dialog because they thought it was too complicated to use, though. The default was also changed after Fedora 21.

6
  • 12
    "experts" should be in quotes. :>
    – jhermann
    Jun 20, 2016 at 14:41
  • 1
    If this doesn’t work (echo $pid is empty), try: pid=$(dconf list /org/gnome/terminal/legacy/profiles:/ | tr -d ":/")
    – rumpel
    Jan 19, 2018 at 12:43
  • @rumpel, hm, the above dconf read ... still works for me on Fedora 26. Your list command returns all profile ids and other entries in that directory. Thus, you'll likely end up with a malformed write command if you use that command substitution. Jan 19, 2018 at 21:17
  • 1
    @rumpel, I've updated the answer. Obtaining the default profile with dconf only works if you have more than one profile configured and/or have changed the default profile setting. Otherwise, the command returns nothing. The gsettings command is more high-level and returns the default value for the default profile if it isn't explicitly set (e.g. when you only have the one default profile). Mar 18, 2018 at 19:20
  • The proposal for making ctrl-shift-click copy a URL to the clipboard is at bugzilla.gnome.org/show_bug.cgi?id=786935 The Ubuntu bug for the regression in which selecting URLs became harder in 15.10, is here, if you want to chime in. bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/1501250
    – nealmcb
    Jun 29, 2018 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.