February 3, 2017·4 min read·engineeringfishkey-bindingsscripting

fish 2.5 makes hybrid editing a named configuration choice

fish 2.5 combines modal editing with Emacs bindings through an explicit preset. The release also adds direct random selection and clearer behavior when leaving background jobs.

Modal editing and Emacs-style shortcuts need not be an all-or-nothing choice in an interactive shell. fish 2.5 supplies a named hybrid binding preset that combines them. That gives users a supported way to retain familiar controls while using Vi's editing modes, instead of reconstructing the combination through individual custom bindings.

The February 3 release notes say there are no major changes from the January beta and direct users upgrading from 2.4 to read its notes as well. For the stable release, the maintainers also fix Home, End and other navigation keys in Vi-style bindings. The new preset and that final correction address related parts of the interactive editing experience.

I value fish's useful defaults and its willingness to give interactive behavior a coherent interface. A named editing preset is useful because configuration can state the intended combination directly, and the shell can maintain the details of how its bindings compose.

The hybrid preset composes existing binding sets

The released hybrid-binding function first clears existing bindings. It then installs the default key bindings in each of the default, insert and visual modes. Finally it invokes the Vi binding setup with --no-erase.

The order matters. The default bindings provide the base, and the Vi setup adds definitions without clearing that base. This is a concrete composition mechanism, not a claim that every possible shortcut from two editors can operate without conflict.

fish_hybrid_key_bindings

Calling the function selects the preset. The implementation also updates the fish_key_bindings variable when necessary. Its comments describe using the variable handler to arrange a repeat call and execute user key bindings through the established setup path.

The release notes connect the new preset to the behavior of fish_vi_key_bindings in fish 2.3.0. That history explains why an explicit hybrid name is useful. A user can choose the combination as a distinct policy instead of depending on an older meaning of the Vi preset.

This also keeps an interactive preference separate from scripting compatibility. Selecting hybrid bindings changes how the command line is edited. It does not turn fish into a POSIX shell or change the grammar expected by a script.

Stable-release fixes cover ordinary keyboard navigation

The stable notes specifically mention Home, End, Insert, Delete, Page Up and Page Down working in Vi-style bindings. These keys are easy to overlook in an explanation centered on modal commands, but they remain part of a normal terminal keyboard.

A mode-aware editor must decide what those keys do in each applicable context. Users do not necessarily stop using dedicated navigation keys when they enable Vi editing. Fixing them prevents the preset from requiring a narrower keyboard vocabulary than the terminal provides.

The broader release also changes fish_mode_prompt into a wrapper around fish_default_mode_prompt. The notes explain that this makes the mode prompt easier to include in custom prompt functions. Mode indication belongs with editing because users need to know which interpretation their next key will receive.

That is a concrete way the shell can support customization without making every custom prompt reimplement its mode display. The default mode prompt remains available as a function that a more elaborate prompt can incorporate.

Random selection becomes a direct operation

The same release improves the random builtin. The versioned reference documents start and end bounds, an optional step and a choice subcommand. A caller can ask for the desired selection directly.

random 10 2 20
random choice staging development

The first command chooses among even integers from ten through twenty, including the endpoints. The second chooses one of the supplied arguments. Neither needs a separate expression to convert a general random integer into the desired range or item selection.

With no arguments, the documented range remains zero through 32767. The bounded forms therefore extend an existing interface instead of replacing its default behavior. A reader must inspect the argument count before interpreting a numeric argument, because range selection and seeding share the same command name.

The one-argument form has a different meaning. It seeds the generator and produces no output. That distinction matters because random 10 is not the syntax for choosing a number below ten in this version. The number of positional arguments selects the operation.

The documentation also says the same seed does not guarantee the same sequence across different systems. A script cannot use this interface to promise cross-platform reproduction merely by recording a seed. The reference explicitly advises against treating the generator as cryptographically secure or statistically accurate.

That leaves a useful role for small interactive choices and incidental script behavior. Selecting a candidate from supplied arguments is convenient, but security tokens and reproducible experiments require guarantees the command does not claim to provide.

I prefer direct selection operations when they remove an easy argument-count or range mistake. Their usefulness depends on retaining those documented limits in any explanation or example.

Exiting a shell now accounts for running background work

The release warns when an exit attempt encounters running background processes. A second exit attempt signals them to terminate. The notes say this aligns the treatment of running background processes with stopped processes.

That is a change in the consequences of leaving an interactive session. A process being in the background does not make it independent of the shell's exit handling. The new warning makes that relationship visible before a repeated exit proceeds.

The distinction is especially useful alongside editing improvements. An interactive shell manages the command-line buffer and also the jobs started from that buffer. Comfortable key bindings do not remove the need for clear behavior when a user closes the session.

Version 2.5 also requires a C++11 toolchain, with specific packaging consequences for older platforms documented in the release notes. That implementation requirement concerns obtaining a working binary. Once installed, the release gives users a named editing combination, working navigation keys and a more explicit warning before exit affects their running jobs.