Autosuggestions 5
| Action | Shortcut |
|---|---|
| Accept suggestionTakes the whole grey suggestion into the line; before the line end the same keys move one character right. | RightorCtrl+F |
| Accept one wordTakes only the next word of the suggestion; elsewhere it jumps a word right, or forward in directory history on an empty line. | Alt+RightorAlt+F |
| Accept one tokenMoves one whole argument right and takes the part of the suggestion it passes over. | Ctrl+Right |
| Accept one big wordJumps to the next space-separated word without stopping at punctuation such as slashes, taking that much of the suggestion. | Shift+Right |
| Remove from historyDeletes the entry being recalled, or the grey suggestion, from the saved command history. | Shift+Delete |
Moving the cursor 8
| Action | Shortcut |
|---|---|
| Move one character leftThe arrow is a shared binding that also works in vi mode; Ctrl + B is the Emacs-mode alias. | LeftorCtrl+B |
| Move one word leftOn an empty command line it steps back through the directory history instead. | Alt+LeftorAlt+B |
| Move one token leftA token is a whole argument, so it skips farther than Alt + Left, which stops at each word. | Ctrl+Left |
| Move one big word leftTreats everything up to the previous space as one word, ignoring punctuation inside it. | Shift+Left |
| Start of lineStays on the current line; Alt + < goes to the start of the whole multi-line command. | HomeorCtrl+A |
| End of linePressed a second time at the line end, it takes the grey suggestion. | EndorCtrl+E |
| Start of whole commandDiffers from Home only when the command spans several lines. | Alt+< |
| End of whole commandLands after the last line of a multi-line command, where End stops at the current line. | Alt+> |
Line editing 22
| Action | Shortcut |
|---|---|
| Delete next characterCtrl + D does the same job but exits fish when the line is empty. | Delete |
| Delete previous character | BackspaceorCtrl+H |
| Delete or exitRemoves the character right of the cursor; on an empty command line it exits fish instead. | Ctrl+D |
| Delete previous wordRemoves a single word; Ctrl + Backspace takes the whole argument. | Alt+Backspace |
| Delete previous argumentGoes further than Alt + Backspace, taking the entire argument behind the cursor. | Ctrl+Backspace |
| Kill to startCuts from the line start up to the cursor into the kill ring, ready for Ctrl + Y. | Ctrl+U |
| Kill to endCuts everything after the cursor on this line; the text can be pasted back with Ctrl + Y. | Ctrl+K |
| Delete path componentCuts back to the previous slash, colon or @ rather than a whole word, keeping the text in the kill ring. | Ctrl+W |
| Cut next wordWith an empty command line it prints the directory history instead. | Alt+D |
| Cut next word or argumentCuts the next word into the kill ring; on macOS it takes the whole next argument. | Ctrl+Delete |
| Cut next argument or wordCuts the next whole argument; on macOS the two keys swap and it takes only a word. | Alt+Delete |
| Paste last killInserts the most recently cut text from fish's kill ring, not from the system clipboard. | Ctrl+Y |
| Cycle older killsRight after Ctrl + Y, swaps the pasted text for the kill before it. | Alt+Y |
| Copy line to clipboardNeeds a clipboard tool such as xsel, xclip, wl-copy or pbcopy to reach the system clipboard. | Ctrl+X |
| Paste from clipboardInserts the system clipboard at the cursor, unlike Ctrl + Y, which uses the kill ring. | Ctrl+V |
| Capitalize word | Alt+C |
| Uppercase current word | Alt+U |
| Swap two characters | Ctrl+T |
| Swap two words | Alt+T |
| Undo last editCtrl + / stands in for Ctrl + _ on terminals that send it that way. | Ctrl+ZorCtrl+_orCtrl+/ |
| Redo undone editBrings back a change that Ctrl + Z took away. | Ctrl+Shift+ZorAlt+/ |
| Space without abbreviationTypes a plain space so the abbreviation before it stays unexpanded; in vi mode only insert mode has it. | Ctrl+Space |
Searching history 8
History searches ignore case unless the search text contains a capital letter. Esc or Page Down stops a search so the search text can be edited.
| Action | Shortcut |
|---|---|
| Search history backwardRecalls older commands that contain the text already typed, anywhere in the line; with an empty line every command matches. | UporCtrl+P |
| Search history forwardSteps to newer commands that contain the typed text, after Up has gone back. | DownorCtrl+N |
| Token searchFinds earlier arguments matching the one under the cursor, rather than whole command lines. | Alt+Up |
| Token search forwardSteps to newer matching arguments during an Alt + Up search. | Alt+Down |
| Token search, Bash styleA second key for the backward token search of Alt + Up, bound for Bash compatibility. | Alt+. |
| History pagerLists matching entries a page at a time; Ctrl + R again pages to older ones and Ctrl + S to newer ones. | Ctrl+R |
| Beginning of history | Page Up |
| End of history | Page Down |
Tab completion 4
| Action | Shortcut |
|---|---|
| Complete current tokenInserts the only match, or the longest common part plus a menu of choices when several fit. | Tab |
| Complete and searchCompletes like Tab and puts the pager straight into its filter field. | Shift+Tab |
| Toggle pager searchOpens a filter field in the completion menu; inside the history pager it moves to newer entries. | Ctrl+S |
| Move through the pagerTab and Shift + Tab also step through the choices while the menu is open. | Arrow keysorPage UporPage Down |
Running commands 6
At an idle prompt the preset Ctrl + C binding is clear-commandline: it empties the line, and the SIGINT behaviour applies to a running program.
| Action | Shortcut |
|---|---|
| Run the command lineWhen a block such as if or for still lacks its end, it starts a new line instead. | Enter |
| Insert a newlineAdds a line even when the command could already run, for writing multi-line commands. | Alt+Enter |
| Interrupt running commandSends SIGINT to the program in the foreground. | Ctrl+C |
| Cancel operationPressed straight after a completion fish inserted unambiguously, it undoes that completion. | EscorCtrl+G |
| Clear screenMoves the text above the prompt into the terminal's scrollback, then redraws a clean screen. | Ctrl+L |
| Toggle commentTurns the command into a comment so it is saved to history unrun; pressed again it removes the comment mark. | Alt+# |
Command helpers 7
In the traditional terminal encoding Esc and Alt look the same, so fish waits fish_escape_delay_ms after Esc to tell them apart; to use Esc followed by a letter as Alt, the documentation suggests raising it, for example to 100.
| Action | Shortcut |
|---|---|
| Show man pageOpens the manual of the command at the cursor, when one is installed. | Alt+HorF1 |
| Describe commandPrints a one-line summary for the command at the cursor. | Alt+W |
| List directoryShows the contents of the working directory, or of the directory argument under the cursor. | Alt+L |
| Open file in pagerOn a script in command position it opens that script in $VISUAL or $EDITOR instead. | Alt+O |
| Append pagerPuts &| less after the job at the cursor so its output scrolls in a pager; $PAGER replaces less when set. | Alt+P |
| Edit in external editorOpens the command line in $VISUAL, or $EDITOR when that is unset, for longer edits. | Alt+EorAlt+V |
| Prepend sudoUses the previous command when the line is empty, and falls back to doas, please or run0 without sudo. | Alt+S |
Vi command mode 27
Key names are case-sensitive in fish, so an upper-case letter in the vi lists is typed with Shift (shown here as Shift + D). A comma, as in d,d, means one key after the other.
| Action | Shortcut |
|---|---|
| Move cursor left | H |
| Move cursor right | L |
| Previous matching commandRecalls older commands containing the typed text; inside a multi-line command it moves up a line. | K |
| Next matching commandGoes to newer matches; inside a multi-line command it moves the cursor down a line. | J |
| Insert at cursor | I |
| Insert at line start | Shift+I |
| Append after cursor | A |
| Append at line end | Shift+A |
| Open line belowStarts a fresh line beneath this one, ready for typing in insert mode. | O |
| Open line aboveStarts a fresh line over this one, ready for typing in insert mode. | Shift+O |
| Start visual modeBegins a selection at the cursor for the visual-mode keys to act on. | V |
| Go to line startUnlike Shift + I, it leaves you in command mode. | 0 |
| Cut whole lineThe removed line goes to the kill ring, so P can paste it back. | DthenD |
| Cut to line endThe text after the cursor goes to the kill ring, ready for P. | Shift+D |
| Paste from kill ring | P |
| Undo last changeCtrl + R brings the change back. | U |
| Redo last undoIn vi command mode Ctrl + R is redo; the history pager sits on / instead. | Ctrl+R |
| Previous matching argumentThe vi key for token search, like Alt + Up: it looks for earlier arguments matching the one under the cursor. | [ |
| Next matching argumentMoves to newer matches during a token search started with [. | ] |
| Open history pagerThe vi counterpart of Ctrl + R in Emacs mode; pressing it again pages to older entries. | / |
| Step cursor leftMoves without deleting anything, unlike Backspace in insert mode. | Backspace |
| Start of command lineGoes to the very beginning of a multi-line command, not just of the current line. | GthenG |
| End of command lineGoes to the end of the last line when the command spans several lines. | Shift+G |
| Toggle character caseFlips upper or lower case at the cursor, then steps one character right. | ~ |
| Lowercase to word end | GthenU |
| Uppercase to word end | GthenShift+U |
| Exit fishA key sequence: type a colon, then q. | :thenQ |
Vi insert mode 3
| Action | Shortcut |
|---|---|
| Enter command modeLeaves insert mode; the mode indicator to the left of the prompt changes with it. | Esc |
| Delete previous characterIn insert mode it erases the character left of the cursor. | Backspace |
| Accept suggestionThe insert-mode key for taking the grey suggestion; in Emacs mode Ctrl + N searches history instead. | Ctrl+N |
Vi visual mode 13
| Action | Shortcut |
|---|---|
| Extend selection a characterLeft grows the selection backward and Right forward, one character per press. | LeftorRight |
| Move cursor left or right | HorL |
| Move cursor up or down | KorJ |
| Extend selection a wordB grows the selection one word backward and W one word forward. | BorW |
| Cut selectionThe selected text goes to the kill ring and the editor drops back to command mode. | DorX |
| Change selectionDeletes the selected text and continues in insert mode. | CorS |
| Cut entire lineTakes the whole line into the kill ring, not only the selection, and returns to command mode. | Shift+X |
| Copy selectionCopies to the kill ring, not the system clipboard, then returns to command mode. | Y |
| Copy to system clipboardUnlike Y, the text lands on the system clipboard rather than in the kill ring. | "then*thenY |
| Toggle selection case | ~ |
| Lowercase selection | GthenU |
| Uppercase selection | GthenShift+U |
| Back to command mode | EscorCtrl+C |
No row on this page matches that filter.
Notes
Suggestions and history
As you type, fish shows a suggestion in grey, drawn from history, completions and valid file paths; Right accepts all of it and Alt + F accepts one word at a time, which is how a long command is reused with a different last argument. Up recalls earlier commands that contain what you have typed, anywhere in the line, and Alt + Up searches by token — finding an earlier argument that matches the one under the cursor — and Ctrl + R opens the history pager, where typing filters the matches. Tab inserts the only completion, or the common part plus a menu of choices.
The Alt shortcuts
Alt + S prepends sudo to the current command, or to the last one when the line is empty — the fix for the "permission denied" you just saw. Alt + E opens the command line in $VISUAL or $EDITOR for anything longer than a line, Alt + L lists the directory under the cursor (or the current one), Alt + P appends a pager, Alt + H opens the man page for the command under the cursor and Alt + W prints a one-line description of it. On macOS, Alt is Option and may need the terminal set to send Meta.
Line editing
Ctrl + A and Ctrl + E jump to the ends of the line, Ctrl + U and Ctrl + K cut to the start and end, and Ctrl + L clears the screen, as in bash. Ctrl + W behaves differently: it cuts back only to the previous /, : or @, one path component at a time, while Alt + Backspace removes a word and Ctrl + Backspace a whole argument. Vi mode is available with fish_vi_key_bindings, and fish_key_reader prints what fish receives for any key, which is the tool for fixing a binding that does not fire.
Questions
How do I switch fish to vi key bindings and back?
Run fish_vi_key_bindings to switch to vi mode, which starts in insert mode; fish_default_key_bindings returns to the Emacs-style set, the default. To keep a choice, set the fish_key_bindings variable to the name of the binding function in config.fish.
How do I stop fish from suggesting a command I mistyped?
Recall it with Up or let it appear as the grey suggestion, then press Shift + Delete: fish removes that entry from the command history.
Why does Ctrl + W delete less than in bash?
In fish Ctrl + W cuts back only to the previous /, : or @, which removes one path component. Use Alt + Backspace for a word or Ctrl + Backspace for a whole argument; Ctrl + Y pastes the cut text back from the kill ring.
How do I find the name fish uses for a key?
Run fish_key_reader and press the key: it prints the key name and a ready line such as bind alt-right 'do something'. Put bind lines in config.fish or in a function called fish_user_key_bindings; bind --erase on a key brings back fish's preset binding.
Sources and checks
- fish-shell 4.9.3 documentation — Interactive use Autosuggestions, tab completion, shared, Emacs-mode and vi-mode bindings, kill ring and history search
- fish-shell 4.9.3 documentation — bind How fish writes key names: modifiers, upper-case letters and key sequences
- fish 4.9.3 source — share/functions/__fish_shared_key_bindings.fish (preset bindings, release tag 4.9.3) Preset bindings the documentation does not list: Alt + #, Alt + ., Page Up, Page Down, Ctrl + C at the prompt
Every row on this page was matched to a line in the documentation above on . A binding that could not be found there is not listed.
Found a wrong or missing key? Tell us and it gets checked against the source. How we verify describes the process and its limits.