<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Fzf on Haseeb Majid</title>
    <link>https://haseebmajid.dev/tags/fzf/</link>
    <description>Recent content in Fzf on Haseeb Majid</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Tue, 19 Sep 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://haseebmajid.dev/tags/fzf/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>TIL: How to Use fzf.fish History Search</title>
      <link>https://haseebmajid.dev/posts/2023-09-19-til-how-to-use-fzf-fish-history-search/</link>
      <pubDate>Tue, 19 Sep 2023 00:00:00 +0000</pubDate>
      <author>Me</author>
      <guid>https://haseebmajid.dev/posts/2023-09-19-til-how-to-use-fzf-fish-history-search/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TIL: How to Use fzf.fish History Search&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I use Fish Shell with fzf and &lt;a href=&#34;https://github.com/PatrickF1/fzf.fish&#34;&gt;fish fzf plugin&lt;/a&gt;.
I installed fzf using nix and home-manager:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-nix&#34; data-lang=&#34;nix&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;n&#34;&gt;programs&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;fzf&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;enable&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;no&#34;&gt;true&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;enableFishIntegration&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;no&#34;&gt;false&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It adds &lt;code&gt;fzf-history-widget&lt;/code&gt; script, which is bound to &lt;code&gt;ctrl+r&lt;/code&gt;, shell reverse history search.
Which we can see when we run this: &lt;code&gt;bind | grep -e fzf-history-widget -e fzf-file-widget&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Whereas I wanted to use the &lt;code&gt;_fzf_search_history&lt;/code&gt; which is made available by that fish fzf plugin.
Now PatrickF1 recommends running the uninstaller script from fzf, but I found another way we can overwrite
the binding by adding the following lines to our &lt;code&gt;fish.config&lt;/code&gt;:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><strong>TIL: How to Use fzf.fish History Search</strong></p>
<p>I use Fish Shell with fzf and <a href="https://github.com/PatrickF1/fzf.fish">fish fzf plugin</a>.
I installed fzf using nix and home-manager:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-nix" data-lang="nix"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="n">programs</span><span class="o">.</span><span class="n">fzf</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">enable</span> <span class="o">=</span> <span class="no">true</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">enableFishIntegration</span> <span class="o">=</span> <span class="no">false</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="p">};</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>It adds <code>fzf-history-widget</code> script, which is bound to <code>ctrl+r</code>, shell reverse history search.
Which we can see when we run this: <code>bind | grep -e fzf-history-widget -e fzf-file-widget</code></p>
<p>Whereas I wanted to use the <code>_fzf_search_history</code> which is made available by that fish fzf plugin.
Now PatrickF1 recommends running the uninstaller script from fzf, but I found another way we can overwrite
the binding by adding the following lines to our <code>fish.config</code>:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fish" data-lang="fish"><span class="line"><span class="cl"><span class="nb">bind</span> <span class="se">\c</span>r _fzf_search_history
</span></span><span class="line"><span class="cl"><span class="nb">bind</span> <span class="na">-M</span> insert <span class="se">\c</span>r _fzf_search_history
</span></span></code></pre></div><p>So now when I press <code>ctrl+r</code> in my shell I used to get this (before):</p>
<p><img
        loading="lazy"
        src="/posts/2023-09-19-til-how-to-use-fzf-fish-history-search/images/fzf_original.png"
        type=""
        alt="FZF"
        
      /></p>
<p>but now I get this (after):</p>
<p><img
        loading="lazy"
        src="/posts/2023-09-19-til-how-to-use-fzf-fish-history-search/images/fish_fzf.png"
        type=""
        alt="FZF Fish"
        
      /></p>
<h2 id="appendix">Appendix</h2>
<ul>
<li>[My nix fish shell config](<a href="https://gitlab.com/hmaji%5D(https://gitlab.com/hmajid2301/dotfiles/-/blob/a34417ed452fe068ec4a91fba7ef0a14fca31b76/home-manager/shells/fish.nix#L48-49)">https://gitlab.com/hmaji](https://gitlab.com/hmajid2301/dotfiles/-/blob/a34417ed452fe068ec4a91fba7ef0a14fca31b76/home-manager/shells/fish.nix#L48-49)</a></li>
</ul>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
