Shift / Ctrl / Option / Cmd text selection for the fish command line — select by character, word or line, and delete the selection with Backspace or Delete.
fish 4.0 or newer. These bindings use fish 4's named keys (ctrl-shift-right)
instead of raw escape sequences. On fish 3.x they silently misbehave — there,
bind backspace ... binds the literal letters b,a,c,k,s,p,a,c,e rather than the
Backspace key, so the selection is never deleted (and typing the word "backspace"
triggers the binding instead). Check with fish --version.
| File | Goes in |
|---|---|
selection.fish |
~/.config/fish/conf.d/ |
__select_extend.fish |
~/.config/fish/functions/ |
__select_clear.fish |
~/.config/fish/functions/ |
__select_delete.fish |
~/.config/fish/functions/ |
Then exec fish.
| Chord | Action |
|---|---|
| Shift + Left/Right | extend selection by character |
| Shift + Up/Down | extend selection by line |
| Ctrl + Shift + Left/Right | extend selection by word |
| Option/Alt + Shift + Left/Right | extend selection by word |
| Shift + Home/End | extend selection to line bounds |
| Cmd + Shift + Left/Right | extend selection to line bounds (macOS) |
| Left/Right, Home/End | move, clearing the selection |
| Ctrl + Arrow, Option + Arrow | move by word, clearing the selection |
| Backspace / Delete | delete the selection, else delete one character |
Not every terminal emits every chord. Run fish_key_reader and press a chord to
see what yours actually reports.
- Up/Down are deliberately not rebound. fish's own handling of them is history
recall, and it is not reproducible from a user binding — there is no
up-or-searchinput function, andup-linealone does not recall history. Rebinding them silently breaks the up-arrow. - Typing over a selection does not replace it. The highlight goes stale rather than the text being overwritten. This is fish behaviour in 4.x as well as 3.x. Press Backspace first, or any arrow key to clear the selection.
- Selection state is read from fish itself via
commandline --selection-startrather than tracked in a shell variable, so it cannot fall out of sync with what the editor actually has selected.