🧠 Second Brain

Search

Search IconIcon to open search

Recursive Search in Terminal with fzf (`ctrl+r`)

Last updated Apr 23, 2024

The videos I got it from:

# Installation

GitHub - junegunn/fzf: :cherry_blossom: A command-line fuzzy finder

1
brew install fzf
1
2
3
4
5
6
7
8
# CTRL-/ to toggle small preview window to see the full command
# CTRL-Y to copy the command into clipboard using pbcopy
export FZF_CTRL_R_OPTS="
  --preview 'echo {}' --preview-window up:3:hidden:wrap
  --bind 'ctrl-/:toggle-preview'
  --bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
  --color header:italic
  --header 'Press CTRL-Y to copy command into clipboard'"

Or I added this file to my fzf/shell/key-bindings.zsh at master · junegunn/fzf · GitHub to my zsh in ~/.fzf.zsh (maybe that’s also done automatically through installing above fzf and zsh shell is automatically picking it up)

# Troubleshoot

# ubuntu WSL2

I had installed the fzf via apt in Lubuntu (sudo apt-get install fzf) but it didn’t work for me, so what I did was clone it to install it and that’s when the error “unknown option: –scheme=history” appeared. What I did was uninstall the fzf (sudo apt-get remove –purge fzf) immediately I pressed CRTL + R and it worked.
unknown option: –scheme=history · Issue #2996 · junegunn/fzf · GitHub

Solution, remove and reinstall with cloning from git:

1
2
3
4
5
sudo apt-get remove --purge fzf

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf

~/.fzf/install

If it does not work yet, try source ~/.zshrc


Origin: Fuzzy Search Your Bash History in Style with fzf — Nick Janetakis
References:
Created 2023-03-09