Rust: Command line shell fish 4.0 supports extended keyboard protocols
fish 4.0 introduces important new features, including extended keyboard protocols. The update brings new customization options for developers.
(Image: Tero Vesalainen/Shutterstock.com)
fish 4.0 has been released and brings with it a long list of changes and revisions. The new version of the "friendly and interactive shell" (fish for short) includes both technical adjustments that affect performance and stability, as well as new features designed to enhance customizability and usability. In addition to syntax highlighting, the shell offers automatic suggestions as you type and advanced tab completion that works without additional configuration.
In fish 4.0, the core code of the shell has been ported from C++ to the Rust programming language. This change affects the dependencies and the way the shell is built, but has no direct impact on end users, according to GitHub.
Changes that are not backwards compatible
There are several changes in fish 4.0 that break backwards compatibility. One of the main changes concerns the bind function, which has been given a new key designation. According to the release notes, the old notation should continue to work in most cases, but in rare cases it may be necessary to adapt a bind statement.
The key combination ctrl-c now calls the new bind function clear-commandline, while the old function remains available as cancel-commandline.
In version 4.0 of fish, the behavior of the random function has been adjusted. In contrast to earlier versions of fish, it now generates different values, even if the same seed (start value) is used. In addition, the development team has adapted the function so that it also works reliably with smaller seeds. These changes improve the consistency and randomness of the numbers generated.
Support for additional keyboard protocols
With the latest version of fish, the shell has revised its support for extended keyboard protocols by integrating the modifyOtherKeys encoding of the terminal emulator XTerm and the progressive improvements of the kitty keyboard protocol. These enhancements make it possible to recognize and use a wider range of key combinations, which, according to the release notes, is of particular benefit to users who use complex inputs with modifier keys such as ctrl, alt and shift. For example, it is now possible to differentiate between ctrl-i and the tab key, although these are treated the same in many environments.
In addition, the bind function of fish has been given a human-readable syntax, which should make it easier to configure key combinations by supporting the use of key and modifier names. In case of problems with terminals displaying unexpected characters in the command line, support for these new protocols can be temporarily disabled.
Videos by heise
Copying made easy
Another important new feature is that fish can now be built as a self-installing binary file. This makes it possible to build fish on one system and copy it to another, where it extracts the required files. If you want to do this, you should execute the following code from the release notes:
cargo install --path . # in a clone of the fish repository
# or `cargo build --release` and copy
/release/fish{,_indent,_key_reader} wherever you want
The new fish_should_add_to_history function can be overridden in fish 4.0 to decide whether a command should be added to the history. Bindings can now also mix special input functions and shell commands.
More information about fish 4.0 can be found in the release notes on GitHub.
(mdo)