2007-09-26 00:14:47 +08:00
|
|
|
\section bind bind - handle fish key bindings
|
2005-09-20 21:31:55 +08:00
|
|
|
|
|
|
|
\subsection bind-synopsis Synopsis
|
2007-09-26 00:14:47 +08:00
|
|
|
<tt>bind [OPTIONS] SEQUENCE COMMAND</tt>
|
2005-09-20 21:31:55 +08:00
|
|
|
|
2007-09-26 00:14:47 +08:00
|
|
|
\subsection bind-description Description
|
2006-09-19 22:52:03 +08:00
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
<tt>bind</tt> adds a binding for the specified key sequence to the
|
|
|
|
specified command.
|
2007-09-26 00:14:47 +08:00
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
SEQUENCE is the character sequence to bind to. These should be written as
|
|
|
|
<a href="index.html#escapes">fish escape sequences</a>. For example, because pressing
|
2008-01-19 08:38:20 +08:00
|
|
|
the Alt key and another character sends that character prefixed with
|
|
|
|
an escape character, Alt-based key bindings can be written using the
|
|
|
|
\c \\e escape. For example, Alt-w can be written as
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
<tt>\\ew</tt>. The control character can be written in much the same way
|
|
|
|
using the \c \\c escape, for example Control-x (^X) can be written as
|
2008-01-19 08:38:20 +08:00
|
|
|
<tt>\\cx</tt>. Note that Alt-based key bindings are case sensitive and
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
Control-based key bindings are not. This is a constraint of text-based
|
2013-08-16 16:45:15 +08:00
|
|
|
terminals, not \c fish.
|
2007-09-26 00:14:47 +08:00
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
The default key binding can be set by specifying a SEQUENCE of the empty
|
|
|
|
string (that is, <code>''</code>). It will be used whenever no
|
2007-09-29 05:36:54 +08:00
|
|
|
other binding matches. For most key bindings, it makes sense to use
|
|
|
|
the \c self-insert function (i.e. <tt>bind '' self-insert</tt> as the
|
2013-04-14 05:17:19 +08:00
|
|
|
default keybinding. This will insert any keystrokes not specifically
|
2007-09-29 05:36:54 +08:00
|
|
|
bound to into the editor. Non-printable characters are ignored by the
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
editor, so this will not result in control sequences being
|
2007-09-29 05:36:54 +08:00
|
|
|
printable.
|
|
|
|
|
2007-09-26 00:14:47 +08:00
|
|
|
If the -k switch is used, the name of the key (such as down, up or
|
|
|
|
backspace) is used instead of a sequence. The names used are the same
|
|
|
|
as the corresponding curses variables, but without the 'key_'
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
prefix. (See \c terminfo(5) for more information, or use <tt>bind
|
|
|
|
--key-names</tt> for a list of all available named keys.)
|
2007-09-26 00:14:47 +08:00
|
|
|
|
|
|
|
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,
|
2007-09-29 05:36:54 +08:00
|
|
|
etc. Use 'bind --function-names' for a complete list of these input
|
|
|
|
functions.
|
2007-09-26 00:14:47 +08:00
|
|
|
|
|
|
|
When COMMAND is a shellscript command, it is a good practice to put
|
|
|
|
the actual code into a <a href="#function">function</a> and simply
|
2007-09-29 05:36:54 +08:00
|
|
|
bind to the function name. This way it becomes significantly easier to
|
|
|
|
test the function while editing, and the result is usually more
|
|
|
|
readable as well.
|
2007-09-26 00:14:47 +08:00
|
|
|
|
2013-08-07 11:18:31 +08:00
|
|
|
If such a script produces output, the script needs to finish by
|
|
|
|
calling 'commandline -f repaint' in order to tell fish that a repaint
|
|
|
|
is in order.
|
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
Key bindings are not saved between sessions by default. To save custom
|
|
|
|
keybindings, edit the \c fish_user_key_bindings function and insert the
|
2013-07-29 16:06:05 +08:00
|
|
|
appropriate \c bind statements.
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
|
|
|
|
The following parameters are available:
|
2012-08-03 17:20:33 +08:00
|
|
|
|
2007-09-26 00:14:47 +08:00
|
|
|
- <tt>-k</tt> or <tt>--key</tt> Specify a key name, such as 'left' or 'backspace' instead of a character sequence
|
|
|
|
- <tt>-K</tt> or <tt>--key-names</tt> Display a list of available key names
|
|
|
|
- <tt>-f</tt> or <tt>--function-names</tt> Display a list of available input functions
|
2005-09-20 21:31:55 +08:00
|
|
|
|
2013-08-07 11:18:31 +08:00
|
|
|
The following special input functions are available:
|
|
|
|
|
|
|
|
- \c backward-char, moves one character to the left
|
|
|
|
- \c backward-delete-char, deletes one character of input to the left of the cursor
|
|
|
|
- \c backward-kill-line, move everything from the beginning of the line to the cursor to the killring
|
|
|
|
- \c backward-kill-word, move the word to the left of the cursor to the killring
|
|
|
|
- \c backward-word, move one word to the left
|
|
|
|
- \c beginning-of-history, move to the beginning of the history
|
|
|
|
- \c beginning-of-line, move to the beginning of the line
|
2013-09-13 11:58:31 +08:00
|
|
|
- \c capitalize-word, make the current word begin with a capital letter
|
2013-08-07 11:18:31 +08:00
|
|
|
- \c complete, guess the remainder of the current token
|
|
|
|
- \c delete-char, delete one character to the right of the cursor
|
|
|
|
- \c delete-line, delete the entire line
|
2013-09-13 13:43:36 +08:00
|
|
|
- \c downcase-word, make the current word lowercase
|
2013-08-07 11:18:31 +08:00
|
|
|
- \c dump-functions, print a list of all key-bindings
|
|
|
|
- \c end-of-history, move to the end of the history
|
|
|
|
- \c end-of-line, move to the end of the line
|
|
|
|
- \c explain, print a description of possible problems with the current command
|
|
|
|
- \c forward-char, move one character to the right
|
|
|
|
- \c forward-word, move one word to the right
|
|
|
|
- \c history-search-backward, search the history for the previous match
|
|
|
|
- \c history-search-forward, search the history for the next match
|
|
|
|
- \c kill-line, move everything from the cursor to the end of the line to the killring
|
|
|
|
- \c kill-whole-line, move the line to the killring
|
|
|
|
- \c kill-word, move the next word to the killring
|
2013-09-13 11:58:31 +08:00
|
|
|
- \c upcase-word, make the current word uppercase
|
2013-08-07 11:18:31 +08:00
|
|
|
- \c yank, insert the latest entry of the killring into the buffer
|
|
|
|
- \c yank-pop, rotate to the previous entry of the killring
|
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
\subsection bind-example Examples
|
2005-09-20 21:31:55 +08:00
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
<tt>bind \\cd 'exit'</tt> causes \c fish to exit when Control-d is pressed.
|
2007-09-26 00:14:47 +08:00
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
<tt>bind -k ppage history-search-backward</tt> performs a history search when the Page Up key is pressed.
|
2005-09-20 21:31:55 +08:00
|
|
|
|