BIND(1)
πΈ NAME πΈ
okay so this is bind from the fish-shell manual, and it's literally the page that handles fish key bindings π
bind β handle fish key bindings
β¨ SYNOPSIS β¨
like, here's the shape of it, bestie:
bind [(-M | --mode) MODE] [(-m | --sets-mode) NEW_MODE] [--preset | --user] [-s | --silent] KEYS COMMAND ...
bind [(-M | --mode) MODE] [--preset] [--user] [--color WHEN] [KEYS]
bind [-a | --all] [--preset] [--user] [--color WHEN]
bind (-f | --function-names)
bind (-K | --key-names)
bind (-L | --list-modes)
bind (-e | --erase) [(-M | --mode) MODE] [--preset] [--user] [-a | --all] | KEYS ...
π DESCRIPTION π
bind manages key bindings. that's the whole vibe. π
If you give it both KEYS and COMMAND, bind adds (or replaces) a binding in MODE. If you give it only KEYS, bind lists any existing bindings for those keys in MODE or in all modes. And if you give it no KEYS argument at all, bind lists all bindings in MODE or in all modes. no cap. π«Ά
KEYS is a comma-separated list of key names. Modifier keys can be specified by prefixing a key name with a combination of ctrl-, alt-, shift- and super- (i.e. the "windows" or "command" key). For example, pressing w while holding the Alt modifier is written as alt-w. Key names are case-sensitive; for example alt-W is the same as alt-shift-w. And ctrl-x,ctrl-e would mean pressing ctrl-x followed by ctrl-e. π
Some keys have names, usually because they don't have an obvious printable character representation. They are:
- the arrow keys
up,down,leftandright, backspace,comma(,),delete,end,enter,escape,f1throughf12.home,insert,menu,minus(-),pageup,pagedown,printscreen,spaceandtab,
These names are case-sensitive. yes, really. lowercase or it's not gonna hit. π
An empty value ('') for KEYS designates the generic binding that will be used if nothing else matches. For most bind modes, it makes sense to bind this to the self-insert function (i.e. bind '' self-insert). This will insert any keystrokes that have no bindings otherwise. Non-printable characters are ignored by the editor, so this will not result in control sequences being inserted. very "safety first" of them honestly β¨
To find the name of a key combination you can use fish_key_reader. π§
COMMAND can be any fish command, but it can also be one of a set of special input functions. These include functions for moving the cursor, operating on the kill-ring, performing tab completion, etc. Use bind --function-names or see below for a list of these input functions. π
Note: If a script changes the commandline, it should finish by calling the repaint special input function. like, fr fr, don't leave the screen looking a mess π
Key bindings may use "modes", which mimics vi's modal input behavior. The default mode is "default" (in vi-mode, that's vi's "normal" mode). Every key binding applies to a single mode; you can specify which one with -M MODE. If the key binding should change the mode, you can specify the new mode with -m NEW_MODE. The mode can be viewed and changed via the $fish_bind_mode variable. If you want to change the mode from inside a fish function, use set fish_bind_mode MODE. iconic. π¦
To save custom key bindings, put the bind statements into config.fish. Alternatively, fish also automatically executes a function called fish_user_key_bindings if it exists. π
π OPTIONS π
The following options are available:
-for--function-namesβ Display a list of available input functions. your lil menu of moves π-Kor--key-namesβ Display a list of available named keys such asbackspace. π₯-Lor--list-modesβ Display a list of defined bind modes. π-M MODEor--mode MODEβ Specify a bind mode that the bind is used in. Defaults to"default". If you use vi bindings, that's the command mode, what vi calls "normal" mode. bestie, it's giving normal-mode energy π¦-m NEW_MODEor--sets-mode NEW_MODEβ Change the current mode toNEW_MODEafter this binding is executed. one binding, one whole vibe shift π«-eor--eraseβ Erase the binding with the given sequence and mode instead of defining a new one. Multiple sequences can be specified with this flag. Specifying-aor--allwith-Mor--modeerases all binds in the given mode regardless of sequence. Specifying-aor--allwithout-Mor--modeerases all binds in all modes regardless of sequence. π this one goes hard, be careful-aor--allβ See--erase. that's it, that's the whole description, go read--eraseπ--presetand--userβ Specify ifbindshould operate on user or preset bindings. User bindings take precedence over preset bindings when fish looks up mappings. By default, allbindinvocations work on the"user"level except for listing, which will show both levels. All invocations except for inserting new bindings can operate on both levels at the same time (if both--presetand--userare given).--presetshould only be used in full binding sets (like when working onfish_vi_key_bindings). β-sor--silentβ Silences error message for unbound sequences. shhh, no thoughts, no errors π€«--color WHENβ Controls when to use syntax highlighting colors when listing bindings.WHENcan beauto(the default, colorize if the output is a terminal),always, ornever. π aesthetic choices matter-hor--helpβ Displays help about using this command. the classic. π«Ά
π¦ SPECIAL INPUT FUNCTIONS π¦
The following special input functions are available. these are the main characters of the keybinding world, honestly:
andβ only execute the next function if the previous succeeded (note: only some functions report success). conditional queen πaccept-autosuggestionβ accept the current autosuggestion. Returns false when there was nothing to accept. π the rejectionbackward-charβ move one character to the left. If the completion pager is active, select the previous completion instead. πbackward-char-passiveβ move one character to the left, but do not trigger any non-movement-related operations. If the cursor is at the start of the commandline, does nothing. Does not change the selected item in the completion pager UI when shown. it's giving "no drama, just vibes" π¦backward-tokenβ move one argument to the left. πbackward-delete-charβ deletes one character of input to the left of the cursor. bye bestie πbackward-kill-tokenβ move the argument to the left of the cursor to the killring. πbackward-kill-lineβ move everything from the beginning of the line to the cursor to the killring. π devastatingbackward-kill-path-componentβ move one path component to the left of the cursor to the killring. A path component is everything likely to belong to a path component, i.e. not any of the following:/={,}'":@ |;<>&, plus newlines and tabs. so specific, so iconic πbackward-kill-wordβ move the word to the left of the cursor to the killring, until the start of the current word (like vim'sdb). π₯backward-kill-bigwordβ move the whitespace-delimited word to the left of the cursor to the killring, until the start of the current word (like vim'sdB). πbackward-path-componentβ move one path component to the left. π§backward-wordβ move one word to the left, stopping at the start of the previous word (like vim'sb, or Emacs'M-bbut differs slightly in word division rules). βbackward-bigwordβ move one whitespace-delimited word to the left, stopping at the start of the previous word (like vim'sB). π¦backward-word-endβ move to the end of the previous word (like vim'sge). πΈbackward-bigword-endβ move to the end of the previous whitespace-delimited word (like vim'sgE). β¨beginning-of-bufferβ moves to the beginning of the buffer, i.e. the start of the first line. πbeginning-of-historyβ move to the beginning of the history. going all the way back, bestie πbeginning-of-lineβ move to the beginning of the line. π«Άbegin-selectionβ start selecting text. highlight mode activated πcancelβ close the pager if it is open, or undo the most recent completion if one was just inserted. nvm bestie, take it back πcancel-commandlineβ cancel the current commandline and replace it with a new empty one, leaving the old one in place with a marker to show that it was cancelled. π ripcapitalize-wordβ make the current word begin with a capital letter. main character energy πclear-commandlineβ empty the entire commandline. poof. gone. πclear-screenβ clears the screen and redraws the prompt. fresh start, new me β¨scrollback-pushβ pushes earlier output to the terminal scrollback, positioning the prompt at the top. This requires the terminal to implement the ECMA-48 SCROLL UP command and cursor position reporting. π techy and specific, we love hercompleteβ guess the remainder of the current token. β¨π€complete-and-searchβ invoke the searchable pager on completion options (for convenience, this also moves backwards in the completion pager). π¦delete-charβ delete one character to the right of the cursor. πdelete-or-exitβ delete one character to the right of the cursor, or exit the shell if the commandline is empty. π dramatic exitdown-lineβ move down one line. β¬οΈdowncase-wordβ make the current word lowercase. no shouting here πend-of-bufferβ moves to the end of the buffer, i.e. the end of the last line; or if already at the end of the commandline, accept the current autosuggestion. πend-of-historyβ move to the end of the history. newest stuff last, iconic π¦end-of-lineβ move to the end of the line. πΈend-selectionβ end selecting text. selection era over πexpand-abbrβ expands any abbreviation currently under the cursor. magic. β¨executeβ run the current commandline. the moment of truth π₯exitβ exit the shell. goodbye bestie πforward-tokenβ move one argument to the right. πforward-charβ move one character to the right; or if at the end of the commandline, accept the current autosuggestion. If the completion pager is active, select the next completion instead. πforward-char-passiveβ move one character to the right, but do not trigger any non-movement-related operations. If the cursor is at the end of the commandline, does not accept the current autosuggestion (if any). Does not change the selected item in the completion pager, if shown. just movement, no plot twists π¦forward-path-componentβ move one path component to the right; or if at the end of the commandline, accept a path component from the current autosuggestion. βforward-single-charβ move one character to the right; or if at the end of the commandline, accept a single char from the current autosuggestion. πforward-wordβ hop one whole word to the right, stopping after the end of the word you're in; or, if you're already chilling at the end of the commandline, accept one word from the current autosuggestion π«Άforward-word-viβ same energy asforward-word, but it stops at the start of the next word (exactly like vim'sw)forward-word-endβ again likeforward-word, except it stops at the end of the next word (vim'se, iykyk)forward-bigwordβ move one whitespace-delimited word to the right, stopping after the end of the current word; or if you're at the end of the commandline, accept one word from the current autosuggestionforward-bigword-viβ likeforward-bigword, but stops at the start of the next word (vim'sW)forward-bigword-endβ likeforward-bigword, but stops at the end of the next word (vim'sE)history-pagerβ pull up the searchable pager on history (incremental search); or, if the history pager is already active, keep searching further backwards in time β³history-deleteβ permanently delete the current history item, either from the history pager or from an active up-arrow history search. Yes, permanently. No undo, bestie πhistory-search-backwardβ search the history for the previous matchhistory-search-forwardβ search the history for the next matchhistory-prefix-search-backwardβ search the history for the previous prefix matchhistory-prefix-search-forwardβ search the history for the next prefix matchhistory-token-search-backwardβ search the history for the previous matching argumenthistory-token-search-forwardβ search the history for the next matching argumenthistory-last-token-search-backwardβ search the history for the previous matching last argumenthistory-last-token-search-forwardβ search the history for the next matching last argumentforward-jumpandbackward-jumpβ read another character, then jump to its next occurrence after/before the cursor β¨forward-jump-tillandbackward-jump-tillβ jump to right before the next occurrencerepeat-jumpandrepeat-jump-reverseβ redo the last jump in the same/opposite directionjump-to-matching-bracketβ jump to the matching bracket if the character under the cursor is a bracket; otherwise, jump to the next occurrence of any right bracket after the cursor. These are the brackets it considers:([{}])jump-till-matching-bracketβ same asjump-to-matching-bracketbut it offsets the cursor to the right for a left bracket, and to the left for a right bracket. The offset applies to both the position you jump from and the position you jump to. In other words, the cursor keeps hopping around inside the brackets but never actually reaches them β off by 1 character, always π. This input function is useful for emulating the ib vi text object. Brackets considered:([{}])kill-tokenβ move the next argument to the killringkill-lineβ move everything from the cursor to the end of the line to the killringkill-path-componentβ move one path component to the killring.kill-selectionβ move the selected text to the killringkill-whole-lineβ move the line (including the following newline) to the killring. If the line is the last line, its preceding newline is also removedkill-inner-lineβ move the line (without the following newline) to the killringkill-wordβ move the next word to the killring, stopping after the end of the killed wordkill-word-viβ move the next word to the killring, stopping at the start of the next word (vim'sdw)kill-bigwordβ move the next whitespace-delimited word to the killring, stopping after the end of the current wordkill-bigword-viβ move the next whitespace-delimited word to the killring, stopping at the start of the next word (vim'sdW)kill-inner-wordβ delete the word under the cursor (vim'sdiw)kill-inner-bigwordβ delete the whitespace-delimited word under the cursor (vim'sdiW)kill-a-wordβ delete the word under the cursor plus the surrounding whitespace (vim'sdaw)kill-a-bigwordβ delete the whitespace-delimited word under the cursor plus the surrounding whitespace (vim'sdaW)nextd-or-forward-wordβ if the commandline is empty, move forward in the directory history; otherwise move one word to the right; or, if you're at the end of the commandline, accept one word from the current autosuggestion. Multitasking icon πorβ only execute the next function if the previous one didn't succeed (heads up: only some functions actually report failure, so don't expect this to be a whole vibe check for everything)pager-toggle-searchβ toggles the search field if the completions pager is visible; or, if used afterhistory-pager, search forwards in timeprevd-or-backward-wordβ if the commandline is empty, move backward in the directory history; otherwise move one word to the leftrepaintβ reexecutes the prompt functions and redraws the prompt (alsoforce-repaintfor backwards-compatibility)repaint-modeβ reexecutes thefish_mode_prompt<>and redraws the prompt. This is useful for vi mode. If nofish_mode_promptexists or it prints nothing, it acts like a normalrepaint.self-insertβ inserts the matching sequence into the command lineself-insert-notfirstβ inserts the matching sequence into the command line, unless the cursor is at the beginningget-keyβ setsfish_keyto the key that was pressed to trigger this binding. Example use:
for i in (seq 0 9)
bind $i get-key 'commandline -i "#$fish_key"' 'set -eg fish_key'
end
suppress-autosuggestionβ remove the current autosuggestion. Returns true if there was a suggestion to remove.swap-selection-start-stopβ go to the other end of the highlighted text without changing the selectiontranspose-charsβ transpose two characters to the left of the cursortranspose-wordsβ transpose two words to the left of the cursortogglecase-charβ toggle the capitalisation (case) of the character under the cursortogglecase-selectionβ toggle the capitalisation (case) of the selectioninsert-line-underβ add a new line under the current lineinsert-line-overβ add a new line over the current lineup-lineβ move up one lineundoandredoβ revert or redo the most recent edits on the command lineupcase-wordβ make the current word uppercaseyankβ insert the latest entry of the killring into the bufferyank-popβ rotate to the previous entry of the killring
β¨ ADDITIONAL FUNCTIONS β¨
Okay so these next ones ship as normal functions, but they are chef's kiss particularly useful for input editing:
up-or-searchanddown-or-searchβ move the cursor or search the history, depending on the cursor position and the current modeedit_command_bufferβ open the visual editor (controlled by theVISUALorEDITORenvironment variables) with the current command-line contents πfish_clipboard_copyβ copy the current selection to the system clipboardfish_clipboard_pasteβ paste the current selection from the system clipboard before the cursorfish_commandline_appendβ append the argument to the command-line. If the command-line already ends with the argument, this removes the suffix instead. Starts with the last command from history if the command-line is empty.fish_commandline_prependβ prepend the argument to the command-line. If the command-line already starts with the argument, this removes the prefix instead. Starts with the last command from history if the command-line is empty.
π EXAMPLES π
Exit the shell when ctrl+d is pressed β classic, iconic, no notes:
bind ctrl-d 'exit'
Perform a history search when pageup is pressed:
bind pageup history-search-backward
Turn on vi key bindings <#vi-mode> and rebind ctrl+c to clear the input line β main character energy fr fr:
set -g fish_key_bindings fish_vi_key_bindings
bind -M insert ctrl-c kill-whole-line repaint
Launch git diff and repaint the commandline afterwards when ctrl+g is pressed:
bind ctrl-g 'git diff' repaint
Swap tab and shift+tab, making tab focus the search field. But if the search field is already active, keep the behavior (tab cycles forward, shift+tab backward). β lowkey galaxy brain π§ β¨:
bind tab '
if commandline --search-field >/dev/null
commandline -f complete
else
commandline -f complete-and-search
end
'
bind shift-tab '
if commandline --search-field >/dev/null
commandline -f complete-and-search
else
commandline -f complete
end
'
π TERMINAL LIMITATIONS π
Bestie. Sit down. Unix terminals, like the ones fish operates in, are at heart 70s technology. Like, actual seventies. They have some limitations that applications running inside them straight-up can't workaround. Not a skill issue, just archaeology πΊ
For instance, historically the control key modifies a character by setting the top three bits to 0. This means:
- Many characters + control are indistinguishable from other keys: ctrl+i is tab, ctrl+j is newline (
\n). Yeah. They're the same key as far as your terminal is concerned π« - Control and shift don't work simultaneously β ctrl+X is the same as ctrl+x. No uppercase-control for you.
Other keys don't have a direct encoding, and are sent as escape sequences. For example right (β) usually sends \e\[C.
Some modern terminals support newer encodings for keys that allow distinguishing more characters and modifiers, and fish enables as many of these as it can, automatically. Slay, honestly π
When in doubt, run fish_key_reader β explore what characters keyboard keys send <>. If that tells you that pressing ctrl+i sends tab, your terminal does not support these better encodings, and so fish is limited to what it sends. Not fish's fault, blame the terminal π₯
β±οΈ KEY TIMEOUT β±οΈ
okay so this is the part where things get spicy πΆοΈ β when you've bound a sequence of multiple characters, there is always the possibility that fish has only seen a part of it, and then it needs to disambiguate between the full sequence and part of it. like, poor fish is sitting there mid-vibe-check not knowing what you're gonna do next π
For example:
bind j,k 'commandline -i foo'
# or `bind jk`
will bind the sequence jk to insert "foo" into the commandline. So far so good, bestie π
β but when you've only pressed "j", fish doesn't know if it should insert the "j" (because of the default self-insert), or wait for the "k". it's literally standing there like π§ "girl... are you done or not"
You can enable a timeout for this, by setting the fish_sequence_key_delay_ms variable to the timeout in milliseconds β¨ If the timeout elapses, fish will no longer wait for the sequence to be completed, and do what it can with the characters it already has. no cap, it just commits π«Ά
The escape key is a special case, because it can be used standalone as a real key or as part of a longer escape sequence, like function or arrow keys. π
Holding alt and something else also typically sends escape, for example holding alt+a will send an escape character and then an "a". So the escape character has its own timeout, configured with fish_escape_delay_ms π
See also Key sequences. iykyk π
π Copyright π
fish-shell developers π
and that's a wrap on BIND(1) fr fr π huge thanks to the fish-shell developers for this one β page version 4.9, dated Sep 08, 2026. go forth and bind responsibly, bestie ππ¦
π¦ where this page comes from
- arch rolling: fish 4.9.3-1 Β· GPL-2.0-only AND BSD-3-Clause AND ISC AND MIT AND PSF-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms