<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Steve Stine</title>
    <description>The latest articles on Forem by Steve Stine (@steve-stine).</description>
    <link>https://forem.com/steve-stine</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3820356%2Feea4f58d-c89c-4c4f-8919-8878cc986e97.png</url>
      <title>Forem: Steve Stine</title>
      <link>https://forem.com/steve-stine</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/steve-stine"/>
    <language>en</language>
    <item>
      <title>Fuzzy Find Everything</title>
      <dc:creator>Steve Stine</dc:creator>
      <pubDate>Thu, 12 Mar 2026 12:26:30 +0000</pubDate>
      <link>https://forem.com/steve-stine/fuzzy-find-everything-54b0</link>
      <guid>https://forem.com/steve-stine/fuzzy-find-everything-54b0</guid>
      <description>&lt;p&gt;Imagine searching, editing, and executing files in your terminal so quickly that the friction disappears.&lt;/p&gt;

&lt;p&gt;You type a loose, typo-filled query like "contrler bugfix" — and instantly see "controller_fix_2025.py" rise to the top of the list, even in a monorepo with thousands of files. No exact spelling required. No tab-mashing through long paths. Just start typing what you half-remember, watch the results narrow in real time, and hit Enter.&lt;/p&gt;

&lt;p&gt;fzf turns any list piped into it (files, command history, git branches, running processes, you name it) into a fast, interactive fuzzy finder. It handles massive directories in milliseconds and makes navigation feel almost thought-to-action.&lt;/p&gt;

&lt;p&gt;Traditional tools demand precision:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ls | grep&lt;/code&gt; needs correct spelling and order&lt;/li&gt;
&lt;li&gt;Tab completion struggles with typos or forgotten segments&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;find&lt;/code&gt; requires full paths or complex flags&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;fzf forgives all of that. Type loosely, in any order, with gaps or abbreviations — it ranks intelligently and shows context so you can decide confidently.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is fuzzy search
&lt;/h2&gt;

&lt;p&gt;Fuzzy search finds approximate matches instead of demanding exact strings. &lt;br&gt;
Type "contrler bugfix" and it finds "controller_fix_2025.py" even with typos, skipped letters, out-of-order words, or abbreviations.&lt;br&gt;
Traditional tools like ls | grep, tab-completion, or find require precise spelling and full paths – frustrating when you half-remember a filename or are working in massive projects.&lt;br&gt;
fzf is the interactive command-line fuzzy finder that turns any list (files, history, git branches, processes…) into a fast, beautiful, searchable interface. &lt;br&gt;
Pipe anything into it via stdin, start typing loosely, and hit Enter – it handles huge directories in milliseconds.&lt;br&gt;
Bonus: It's not just files. fzf supports Ctrl+R history search, directory jumping, killing processes, and more. &lt;br&gt;
Once set up, it becomes muscle memory.&lt;br&gt;
In this guide, we'll install fzf, enable its standard functions, then go deep into previews, custom scripts, and keybinds that make your terminal feel FAST.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to get it
&lt;/h2&gt;

&lt;p&gt;Installing fzf with your package manager is the most straight forward method.&lt;/p&gt;

&lt;p&gt;For linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Debian and Ubuntu&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;fzf

&lt;span class="c"&gt;# Fedora&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;fzf

&lt;span class="c"&gt;# Arch&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;pacman &lt;span class="nt"&gt;-S&lt;/span&gt; fzf

&lt;span class="c"&gt;# Gentoo&lt;/span&gt;
emerge &lt;span class="nt"&gt;--ask&lt;/span&gt; app-shells/fzf

&lt;span class="c"&gt;# OpenSUSE&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;zypper i fzf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are also package managers for Windows.&lt;br&gt;
&lt;a href="https://chocolatey.org/" rel="noopener noreferrer"&gt;Chocolatey&lt;/a&gt;, if you have admin access:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;choco install fzf -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or &lt;a href="https://scoop.sh/" rel="noopener noreferrer"&gt;Scoop&lt;/a&gt; if you don't:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="kd"&gt;scoop&lt;/span&gt; &lt;span class="kd"&gt;install&lt;/span&gt; &lt;span class="kd"&gt;fzf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And macOS can install with &lt;a href="https://brew.sh/" rel="noopener noreferrer"&gt;Homebrew&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;fzf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The most up to date releases for all operating systems are also available &lt;a href="https://github.com/junegunn/fzf/releases" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Standard functions
&lt;/h2&gt;

&lt;p&gt;The newer versions of fzf come packaged with standard keybinds and search scripts.&lt;br&gt;
You can enable them on linux with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'eval "$(fzf --bash)"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reload your shell (source ~/.bashrc) or restart terminal.&lt;br&gt;
This unlocks:&lt;/p&gt;

&lt;p&gt;Ctrl+T → fuzzy file search in current dir (inserts path)&lt;br&gt;
Ctrl+R → fuzzy command history search&lt;br&gt;
Alt+C → fuzzy cd to subdirectory&lt;/p&gt;

&lt;p&gt;Stop here and your searching is already superior than stock. &lt;br&gt;
Keep reading for previews, custom scripts, and global keybinds.&lt;/p&gt;
&lt;h2&gt;
  
  
  Power User: keybinds and shell integration
&lt;/h2&gt;

&lt;p&gt;If you're not afraid to get your hands a bit dirty, fzf can become very powerful.&lt;br&gt;
This section is about minimizing the time it takes to get where the work is.&lt;/p&gt;
&lt;h3&gt;
  
  
  File previews
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3ge33d96va8h6mpopf4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3ge33d96va8h6mpopf4.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using the --preview flag, you can see what you're about to open, edit, or execute.&lt;/p&gt;

&lt;p&gt;Here's a simple example using the preview flag to try out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fzf &lt;span class="nt"&gt;--preview&lt;/span&gt; &lt;span class="s1"&gt;'cat {}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will try to show you what's in the file while you're searching.&lt;br&gt;
This is pretty good, but we can do better:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;fzf --preview 'bat --color=always --style=numbers {}'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This one shows the same text, but with syntax highlighting and line numbers.&lt;br&gt;
It uses bat or batcat to do the highlighting and numbers.&lt;br&gt;
To install bat:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;bat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the exact command that's executing in the above screenshot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd &lt;span class="nt"&gt;--type&lt;/span&gt; f &lt;span class="nt"&gt;--hidden&lt;/span&gt; &lt;span class="nt"&gt;--exclude&lt;/span&gt; .git &lt;span class="nb"&gt;.&lt;/span&gt; / 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
fzf &lt;span class="nt"&gt;--height&lt;/span&gt; 75% &lt;span class="nt"&gt;--layout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;reverse &lt;span class="nt"&gt;--border&lt;/span&gt; &lt;span class="nt"&gt;--preview&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="s1"&gt;'if file --mime-type {} | rg -q text; then bat --color=always --style=numbers {}; else cat {}; fi'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's one long command!&lt;br&gt;
This is what's going on:&lt;br&gt;
First it calls the find command, fd, to search for files.&lt;br&gt;
The second line takes the results and gives it to fzf.&lt;br&gt;
And we've already seen that the preview flag and bat give highlighted outputs.&lt;/p&gt;

&lt;p&gt;I'll be relying on this command for the rest of the article.&lt;br&gt;
Getting this to work as pictured above, you'll need to install a few more programs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;bat fd-find ripgrep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;fd or fd-find is a fast search program.&lt;br&gt;
And rg or ripgrep is a fast regular expression search tool.&lt;/p&gt;
&lt;h3&gt;
  
  
  Find and execute scripts
&lt;/h3&gt;

&lt;p&gt;We're going to use the above command and execute scripts with a function in .bashrc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fzf_execute&lt;span class="o"&gt;()&lt;/span&gt; 
&lt;span class="o"&gt;{&lt;/span&gt;                                                              
    &lt;span class="nv"&gt;script&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;fd &lt;span class="nt"&gt;--type&lt;/span&gt; f &lt;span class="nt"&gt;--hidden&lt;/span&gt; &lt;span class="nt"&gt;--exclude&lt;/span&gt; .git &lt;span class="nt"&gt;--exclude&lt;/span&gt; /proc &lt;span class="nt"&gt;--exclude&lt;/span&gt; / sys &lt;span class="nb"&gt;.&lt;/span&gt; / 2&amp;gt;/tmp/fzf_fd_errors.log | fzf &lt;span class="nt"&gt;--height&lt;/span&gt; 75% &lt;span class="nt"&gt;--layout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;reverse &lt;span class="nt"&gt;--border&lt;/span&gt; &lt;span class="nt"&gt;--preview&lt;/span&gt; &lt;span class="s1"&gt;'if file --mime-type {} | rg -q text; then bat --color=always --style=numbers {}; else cat {}; fi'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;                                    
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then                                             
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/fzf_selected_script                           
        &lt;span class="nv"&gt;$HOME&lt;/span&gt;/Configs/fzf/fzf_execute.sh                                     
    &lt;span class="k"&gt;fi&lt;/span&gt;                                                                      
&lt;span class="o"&gt;}&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, typing fzf_execute in your terminal will start the search.&lt;br&gt;
The if statement writes the path of the selected file to a temporary location and calls a script.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;#########################&lt;/span&gt;
&lt;span class="c"&gt;# Reads a path to file  #&lt;/span&gt;
&lt;span class="c"&gt;# from tmp and tries to # &lt;/span&gt;
&lt;span class="c"&gt;# execute it; .sh .py   #&lt;/span&gt;
&lt;span class="c"&gt;#                       #&lt;/span&gt;
&lt;span class="c"&gt;# tmp is fed by fzf f() #&lt;/span&gt;
&lt;span class="c"&gt;# out in .bashrc        #&lt;/span&gt;
&lt;span class="c"&gt;#########################&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /tmp/fzf_selected_script &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi

&lt;/span&gt;&lt;span class="nv"&gt;selected_script&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /tmp/fzf_selected_script&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Convert relative path to absolute path&lt;/span&gt;
&lt;span class="nv"&gt;selected_script&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;realpath&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi

&lt;/span&gt;&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /tmp/fzf_selected_script

&lt;span class="c"&gt;# Get the file extension (lowercase)&lt;/span&gt;
&lt;span class="nv"&gt;extension&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;selected_script&lt;/span&gt;&lt;span class="p"&gt;##*.&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="s1"&gt;'[:upper:]'&lt;/span&gt; &lt;span class="s1"&gt;'[:lower:]'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Function to open/execute the file based on its extension&lt;/span&gt;
open_file&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$extension&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in
        &lt;/span&gt;sh&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="c"&gt;# Execute bash scripts&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
                &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
            &lt;span class="k"&gt;else
                &lt;/span&gt;bash &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
            &lt;span class="k"&gt;fi&lt;/span&gt;
            &lt;span class="p"&gt;;;&lt;/span&gt;
        py&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="c"&gt;# Run Python scripts&lt;/span&gt;
            python3 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;;;&lt;/span&gt;
        xlsx|ods|csv&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="c"&gt;# Open spreadsheets with LibreOffice Calc&lt;/span&gt;
            libreoffice &lt;span class="nt"&gt;--calc&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;amp;
            &lt;span class="p"&gt;;;&lt;/span&gt;
        docx|odt&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="c"&gt;# Open documents with LibreOffice Writer&lt;/span&gt;
            libreoffice &lt;span class="nt"&gt;--writer&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;amp;
            &lt;span class="p"&gt;;;&lt;/span&gt;
        pdf&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="c"&gt;# Open PDFs with default PDF viewer&lt;/span&gt;
            xdg-open &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;amp;
            &lt;span class="p"&gt;;;&lt;/span&gt;
        jpg|jpeg|png|gif&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="c"&gt;# Open images with default image viewer&lt;/span&gt;
            gimp &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;amp;
            &lt;span class="p"&gt;;;&lt;/span&gt;
        mp4|mov|avi|mkv|mp3|flac&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="c"&gt;# Open videos with default video player&lt;/span&gt;
            vlc &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;amp;
            &lt;span class="p"&gt;;;&lt;/span&gt;
        txt|md|log&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="c"&gt;# Open text files with default text editor&lt;/span&gt;
            vim &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;amp;
            &lt;span class="p"&gt;;;&lt;/span&gt;
        &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="c"&gt;# Fallback: Try to open with default application&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;command&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; xdg-open &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null 2&amp;gt;&amp;amp;1&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
                &lt;/span&gt;xdg-open &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;amp;
            &lt;span class="k"&gt;else
                &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: No handler found for file extension '&lt;/span&gt;&lt;span class="nv"&gt;$extension&lt;/span&gt;&lt;span class="s2"&gt;'"&lt;/span&gt;
                &lt;span class="nb"&gt;exit &lt;/span&gt;1
            &lt;span class="k"&gt;fi&lt;/span&gt;
            &lt;span class="p"&gt;;;&lt;/span&gt;
    &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Check if the file is executable and run directly if it is&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$extension&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"sh"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$selected_script&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;else
    &lt;/span&gt;open_file
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"fzf_script.sh" will take the file path an determine what filetype it is and open it.&lt;br&gt;
So if it's a media file, it'll open it with vlc; text file, vim; and so on.&lt;br&gt;
For python and bash scripts (or any other you choose), it will try execute them.&lt;/p&gt;

&lt;p&gt;Now, I can type "fzf_script" in my terminal, search for a docx file, and launch libreoffice to open it.&lt;br&gt;
Changing fzf_script.sh will be necessary to use your preferred programs like openoffice or kate.&lt;/p&gt;
&lt;h3&gt;
  
  
  Find and edit files
&lt;/h3&gt;

&lt;p&gt;If you want to edit files in your favorite text editor, add another .bashrc function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fzf_edit&lt;span class="o"&gt;()&lt;/span&gt; 
&lt;span class="o"&gt;{&lt;/span&gt;                                                        
    &lt;span class="nv"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;fd &lt;span class="nt"&gt;--type&lt;/span&gt; f &lt;span class="nt"&gt;--hidden&lt;/span&gt; &lt;span class="nt"&gt;--exclude&lt;/span&gt; .git &lt;span class="nb"&gt;.&lt;/span&gt; / 2&amp;gt;/dev/null | fzf &lt;span class="nt"&gt;--height&lt;/span&gt; 75% &lt;span class="nt"&gt;--layout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;reverse &lt;span class="nt"&gt;--border&lt;/span&gt; &lt;span class="nt"&gt;--preview&lt;/span&gt; &lt;span class="s1"&gt;'if file --mime-type {} | rg -q text; then bat --color=always --style=numbers {}; else cat {}; fi'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;        

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then                                                 
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/fzf_selected_file                                   
        ~/Configs/fzf/fzf_vim.sh                                           
    &lt;span class="k"&gt;fi&lt;/span&gt;                                                                        
&lt;span class="o"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice our find command is almost the same as before, just excluding less files.&lt;br&gt;
We also call a different script in our if statement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash                                                                 &lt;/span&gt;
&lt;span class="c"&gt;#########################                                                   &lt;/span&gt;
&lt;span class="c"&gt;# Reads file path from  #                                                   &lt;/span&gt;
&lt;span class="c"&gt;# tmp and tries to open #&lt;/span&gt;
&lt;span class="c"&gt;# file in vim           #&lt;/span&gt;
&lt;span class="c"&gt;#                       #&lt;/span&gt;
&lt;span class="c"&gt;# tmp fed by fzf f() in #&lt;/span&gt;
&lt;span class="c"&gt;# .bashrc               #&lt;/span&gt;
&lt;span class="c"&gt;#########################&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /tmp/fzf_selected_file &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"No file selected by fzf"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi

&lt;/span&gt;&lt;span class="nv"&gt;selected_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /tmp/fzf_selected_file&lt;span class="si"&gt;)&lt;/span&gt;

vim &lt;span class="nt"&gt;-u&lt;/span&gt; ~/Configs/.vimrc &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;selected_file&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /tmp/fzf_selected_file

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will try to open the selected file in a text editor only.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding keybinds
&lt;/h3&gt;

&lt;p&gt;fzf is most useful when the functions and scripts above are triggered from simple key binds.&lt;/p&gt;

&lt;p&gt;In your .bashrc add these at the bottom:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;bind&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'\C-x'&lt;/span&gt;                                                              
&lt;span class="nb"&gt;bind&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="s1"&gt;'"\C-x": fzf_execute'&lt;/span&gt;                                                

&lt;span class="nb"&gt;bind&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'\C-f'&lt;/span&gt; &lt;span class="c"&gt;# Remove current binding                                     &lt;/span&gt;
&lt;span class="nb"&gt;bind&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="s1"&gt;'"\C-f": fzf_edit'&lt;/span&gt; &lt;span class="c"&gt;# start file search function &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"bind -r" will remove all functionality currently associated with that key combination.&lt;br&gt;
"bind -x" will then add the functionality you want.&lt;/p&gt;

&lt;p&gt;The first line removes all functionality associated with ctrl-x.&lt;br&gt;
The second line associates the ctrl-x key combination with the bash function fzf_script.&lt;/p&gt;

&lt;p&gt;Now, while at a terminal, pressing ctrl-x will start your search to open or execute any file.&lt;br&gt;
Pressing ctrl-f will now start your search to edit any file.&lt;/p&gt;

&lt;p&gt;From here, you should be able to add your own customized keybinds and scripts.&lt;/p&gt;

</description>
      <category>cli</category>
      <category>productivity</category>
      <category>linux</category>
      <category>fzf</category>
    </item>
  </channel>
</rss>
