Introduction
Introduction Statistics Contact Development Disclaimer Help
Title: Use fzf for ksh history search
Author: Solène
Date: 17 October 2021
Tags: openbsd shell ksh fzf
Description:
# Introduction
fzf is a powerful tool to interactively select a line among data piped
to stdin, a simple example is to pick a line in your shell history and
it's my main fzf use.
fzf ships with bindings for bash, zsh or fish but doesn't provide
anything for ksh, OpenBSD default shell. I found a way to run it with
Ctrl+R but it comes with a limitation!
This setup will run fzf for looking a history line with Ctrl+R and will
run it without allowing you to edit the line! /!\
# Configuration
In your interactive shell configuration file (should be the one set in
$ENV), add the following function and binding, it will rebind Ctrl+R to
fzf-histo function that will look into your shell history.
```
function fzf-histo {
RES=$(fzf --tac --no-sort -e < $HISTFILE)
test -n "$RES" || exit 0
eval "$RES"
}
bind -m ^R=fzf-histo^J
```
Reload your file or start a new shell, Ctrl+R should now run fzf for a
more powerful history search. Don't forget to install fzf package.
You are viewing proxied material from dataswamp.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.