git-bashwindows-terminal

Double-click to select text in Windows Terminal selects only one word


I'm trying to setup the new Windows Terminal for using git-bash. This is my current profile:

{
    "guid": "{00000000-0000-0000-ba54-000000000002}",
    "tabTitle": "Git Bash",
    "copyOnSelect": true,
    "acrylicOpacity" : 0.75,
    "closeOnExit" : true,
    "colorScheme" : "Campbell",
    "commandline" : "\"%PROGRAMFILES%\\git\\bin\\bash.exe\" --login -i -l",
    "cursorColor" : "#FFFFFF",
    "cursorShape" : "bar",
    "fontFace" : "Consolas",
    "fontSize" : 12,
    "historySize" : 9001,           
    "name" : "Git Bash",
    "padding" : "0, 0, 0, 0",
    "snapOnInput" : true,
    "startingDirectory" : "C:\\git",
    "useAcrylic" : false,
    "wordDelimiters": ":",
    "icon" : "%PROGRAMFILES%\\git\\mingw64\\share\\git\\git-for-windows.ico"

A bit of a show stopper for using the Windows Terminal is the fact that when selecting text using double-click it only selects one word, instead of a more intelligent selection (like a complete path).

I've tried using the setting "wordDelimiters:" with setting like:

`wordDelimiters: ":"` 

or

`wordDelimiters: "()'-:,.;<>~!@#$%^&*|+=[]{}~?"`

but it doesn't seem to have any affect on what text is selected on double-click.

Expected behaviour when I double-click on 'my' is that it select the whole path (file name included). Instead it just selects 'my'. Path/to/my/file.txt

Does anyone know how get this to work, like it does in native git-bash?


Solution

  • Put the wordDelimiters setting in the global section of your settings.json file, not within the "profiles" array. I finally figured this out by looking at the documentation link at the top of the file, it is probably a good place to look when trying to add new settings.

    // For documentation on these settings, see: https://aka.ms/terminal-documentation

    enter image description here

    P.S., for future viewers of this answer who may not know where the aforementioned settings.json file is, you can access it by selecting Settings in the Windows Terminal dropdown menu while holding Shift to open the settings.json file in your default text editor. For more details, check this Microsoft Learn resource out.