I've got what I wanted with wezterm + powershell. I can edit my commands the same way I edit any text anywhere in the system, both in Windows and Linux, and I can copy-paste back and forth between terminal and any other app. This is awesome. This is freedom. This is UX done right.
I will paste below some observations I've made.
Possible solutions for Bash
- https://github.com/jirutka/zsh-shift-select - plugin for zsh as pointed out by @stupid_asshole69@hexbear.net and several other sources;
- https://github.com/akinomyoga/ble.sh - ReadLine replacement for Bash (most promising);
- https://github.com/magenta404/natural-selection - plugin for FishShell;
- https://www.reddit.com/r/pop_os/comments/p0jjno/how_to_use_shift_arrow_keys_to_select_text_in/ - most useful source on this topic.
Blesh
https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A74-Editing
- Super simple installation.
- Home/End - Jump to start/end as expected. ✅
- Ctrl+Backspace removes left char instead of left word. ❌
- Ctrl+Delete removes next word as it should. ✅
- Shift+arrows - char-wise text selection ✅
- Shift+Ctrl+arrows - word-wise text selection ✅
- Shift+Home/End don't do anything. ❌
- Backspace/Delete: When smth is selected they delete it. ✅
- Copy/Paste/Cut: ❌
- It's Alt+W/Ctrl+Y/Ctrl+W instead of Ctrl+C/Ctrl+V/Ctrl+X.
- All work with selection as expected.
- All work with internal buffer instead of system clipboard.
- System clipboard:
- Can't copy selection to clipboard, can't paste clipboard into selection.
- Ctrl+Shift+C/V work as they do in vanilla bash: copy what is selected with mouse to clipboard, paste from clipboard.
- Ctrl+C prints current command and starts new one like in vanilla bash.
zsh-shift-select
- Stated to have best compatibiliy with Alacritty.
- Alacritty requires Cargo (440MB).
cannot install package alacritty 0.16.1, it requires rustc 1.85.0 or newer, while the currently active rustc version is 1.75.0Fail. Will use Gnome Terminal instead.
- Alacritty requires Cargo (440MB).
- Needs zsh, super simple installation.
- Zsh should be default shell,
gnome-shell crashed with SIGSEGV. - Plugin itself has simple installation, just git clone .zsh file and source it in
.zshrc
- Zsh should be default shell,
- Ctrl+arrows - prints CD instead of moving word-wise ❌
- Ctrl+Backspace, Ctrl+Delete - are not deleting left/right word ❌
- Home/End - Jump to start/end as expected. ✅
- Shift+Left/Right - char-wise text selection ✅
- Shift+Ctrl+arrows - word-wise text selection ✅
- Shift+Home/End don't do anything. ❌
- Shift+Up/Down - Select one line up/down ✅
- Backspace/Delete - When smth is selected - delete it. ✅
- Copy/Paste/Cut: ❌
- Documented as Alt+W/Ctrl+Y/Ctrl+W instead of Ctrl+C/Ctrl+V/Ctrl+X.
- Alt+W/Ctrl+Y work as copy/paste.
- Ctrl+W removes previous word instead of Cut selection.
- Work with internal buffer instead of system clipboard.
- System clipboard:
- Ctrl+Shift+C/V work as they do in blesh and vanilla bash.
- Can't copy selection to clipboard, can't paste clipboard into selection.
- Ctrl+C prints current command and starts new one like in vanilla bash.
wezterm + Powershell
PSReadLine starts with EditMode = Emacs by default.
Set-PSReadLineOption -EditMode Windows Fixes Ctrl+arrows, Ctrl+backspace, Shift+Ctrl+arrows.
Set-PSReadLineKeyHandler -Chord Ctrl+Delete -Function KillWord - Fixes Ctrl+Delete.
Set-PSReadLineKeyHandler -Chord Ctrl+o -Function AddLine - allows Ctrl+o instead of Shift+Enter to create a new line without trying to execute. Shift+Enter is not possible in Linux.
Reassigning Shift+Home/End in Gnome Terminal from scrolling viewport to something else is a rabbit hole, so I switched to wezterm, which fixed Shift+Home/End, and apparently also fixed a bug of Shift+arrows printing D;D;D; instead of selecting. But broke Shift+Ctrl+arrows. But you can fix it back by disabling this assignment in lua config.
Ctrl+C/V/X work fine, but without system clipboard synchronization. To fix it, install xclip. If it makes terminal freeze on Ctrl+C/X, update PSReadLine module.
- Ctrl+arrows ✅
- Ctrl+Backspace, Ctrl+Delete ✅
- Home/End ✅
- Shift+Left/Right ✅
- Shift+Ctrl+arrows ✅
- Shift+Home/End ✅
- Shift+Up/Down ❌
- Shift+Enter - Ctrl+o instead ✅
- Ctrl+C,Ctrl+V,Ctrl+X - Flawless ✅
Windows + conhost + Powershell Core
PSReadLine starts with EditMode = Windows by default.
- Ctrl+arrows ✅
- Ctrl+Backspace, Ctrl+Delete ✅
- Home/End ✅
- Shift+Left/Right ✅
- Shift+Ctrl+arrows ✅
- Shift+Home/End ✅
- Shift+Up/Down ❌
- Shift+Enter ✅
- Esc - clear current command ✅
- Ctrl+C,Ctrl+V,Ctrl+X - Flawless, all with system clipboard. ✅