Short answer:
I would recommend upgrading to Windows Terminal, the (relatively) new terminal replacement in Windows. In new installations of Windows 11 22H2, it is now the default terminal for PowerShell, CMD, WSL, and any other "console-mode" application.
The latest release of Windows Terminal (1.15) has added support for "Mark mode", which is probably the closest you will get to the functionality you are requesting. You can activate mark-mode with Ctrl+Shift+M (which is configurable). Once activated, you can then use the Ctrl+(Shift)+Left/Right keybindings to move and select words.
Explanation:
First, it's important to understand the difference between the Shell and the Terminal:
PowerShell and Bash (in Ubuntu in WSL) are shells, which are really just specialized text/console-mode applications for interfacing with other text/console-mode applications (such as Linux ls
or Windows ipconfig.exe
).
Inside the shell, there's an input handler for processing the actual keystrokes. This is typically the Linux readline
library for Bash in Ubuntu. In recent PowerShell releases, it's PSReadline.
A terminal, on the other hand, is the windowed application inside which your text-mode applications run.
Windows provides two built-in terminals in the latest release:
The Windows Console Host is the legacy, 25-year old or so terminal that you are likely seeing when running either PowerShell or Ubuntu/WSL.
Windows Terminal is the (fairly) new replacement. It's modern, open-source, feature-rich, and customizable -- None of which apply to the older Console Host. It's the default terminal starting with new installations of Windows 11 22H2, and can be set as the default in Windows 11 21H2.
It also runs just fine under Windows 10, but not as "default". For instance, you can run PowerShell by starting Windows Terminal and launching the PowerShell profile, but just running "PowerShell" from the Start menu will use the older Console Host.
There are quite a few third-party terminals for Windows as well, and even more for Linux.
PuTTY is a bit of a hybrid, since it bundles both its terminal and text-mode application (the SSH client) into one. But the features are actually separate:
pterm.exe
provides the terminal functionality without the SSH client
plink.exe
provides the SSH client that you can run in a different terminal
So what the heck does this have to do with selecting words?!
Ah, we're getting there ;-). When you press any key in Windows, it has to get processed somewhere:
First, a key might be handled by Windows itself. For instance, pressing Alt+Tab tells Windows to switch/cycle between open windows/applications. If a key is handled by Windows itself, it typically isn't sent to any other application.
Next1, the keystroke is sent to the application, which is the terminal in your case. Console Host doesn't handle many keys itself, but Windows Terminal includes a large number of keybindings, most all of which are customizable. For instance, pressing Ctrl+Shift+T in Windows Terminal will open a new tab with the default profile.
1 I'm over-simplifying here. It's possible for other applications to "hook" the keyboard as well.
If a key isn't handled by the terminal, then the terminal is going to send it on to the text/console application (shell), or more accurately its input handler (or whatever other application is running, such as vim
/nano
/etc.).
This is what is happening with your Ctrl+Shift+Left/Right keys.
So can I configure Bash, the shell, to select words using Ctrl+Shift+Left/Right like PowerShell?
Unfortunately, no. Keep in mind that Windows PowerShell has pretty much always existed in an environment where there is a known clipboard (the Windows clipboard). That means that it (and its readline) could always assume that you can select and copy text to the clipboard using the keyboard.
Bash, on the other hand, started out as a pure-console application that could be used without any graphical, windowing system. It can run in a pure-console (no clipboard), Windows (clip.exe
), X (where text might be passed to xsel
), macOS, and others. There's just no mechanism in place for it to copy to a clipboard. Some other text-mode applications have implemented a configurable clipboard option where you could configure (for example), clip.exe
to be the clipboard application to receive copied text, but Bash has not done this.
So we come back to my original suggestion -- Use Windows Terminal, which does provide this capability, albeit with slightly less convenient keybindings since you have to first get into mark-mode with Ctrl+Shift+M.
What about PuTTY?
I'm not aware of any way to configure PuTTY to do this, but I'm going to mostly skip it since:
I haven't used PuTTY since WSL came out. The OpenSSH client in Ubuntu provides everything I need, and the config files for OpenSSH are much more portable than those for PuTTY (which stores information in the Windows registry by default).
Regardless, the configuration of hotkeys in PuTTY would be a bit off-topic here on Ask Ubuntu unless we were covering configuring the Ubuntu/Bash shell inside it.
With that in mind, I'd personally recommend what I've done -- Since you are already using Ubuntu in WSL, just transition to the OpenSSH client there if it fits your workflow. Then you can use Windows Terminal for all your needs -- PowerShell, WSL, and SSH -- With tabs and mark-mode for all.