{"id":11200,"date":"2019-03-11T05:17:02","date_gmt":"2019-03-11T05:17:02","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11200"},"modified":"2019-03-11T05:17:02","modified_gmt":"2019-03-11T05:17:02","slug":"fzf-a-quick-fuzzy-file-search-from-linux-terminal","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/11\/fzf-a-quick-fuzzy-file-search-from-linux-terminal\/","title":{"rendered":"Fzf \u2013 A Quick Fuzzy File Search from Linux Terminal"},"content":{"rendered":"<p><strong>Fzf<\/strong>\u00a0is a tiny, blazing fast, general-purpose, and cross-platform command-line fuzzy finder, that helps you to search and open files quickly in Linux and Windows operating system. It is portable with no dependencies and has a flexible layout with support for Vim\/Neovim plugin, key bindings, and fuzzy auto-completion.<\/p>\n<p>The following GIF shows how it works.<\/p>\n<p align=\"center\"><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/junegunn\/i\/master\/fzf.gif\" alt=\"Fzf - File Finder for Linux\" data-lazy-loaded=\"true\" \/><\/p>\n<p>To install\u00a0<strong>Fzf<\/strong>, you need to git clone the fzf\u2019s Github repository to any directory and run install script as shown on your Linux distribution.<\/p>\n<pre>$ git clone --depth 1 https:\/\/github.com\/junegunn\/fzf.git ~\/.fzf\r\n$ cd ~\/.fzf\/\r\n$ .\/install\r\n<\/pre>\n<p>After running the script, you will be prompted to enable fuzzy auto-completion, key bindings and update your shell configuration file. Answer\u00a0<code>y<\/code>\u00a0(for\u00a0<strong>yes<\/strong>) to the questions as shown in the following screenshot.<\/p>\n<div id=\"attachment_30993\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/run-fzf-installation-script.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30993\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/run-fzf-installation-script.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/run-fzf-installation-script.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/run-fzf-installation-script-768x457.png 768w\" alt=\"Install Fzf in Linux\" width=\"802\" height=\"477\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install Fzf in Linux<\/p>\n<p>On\u00a0<strong>Fedora 26<\/strong>\u00a0and above, and\u00a0<strong>Arch Linux<\/strong>, you can install it via a package manager as shown.<\/p>\n<pre>$ sudo dnf install fzf\t#Fedora 26+\r\n$ sudo pacman -S fzf\t#Arch Linux \r\n<\/pre>\n<p>Now that you have installed\u00a0<strong>fzf<\/strong>, you can start using it. When you run\u00a0<strong>fzf<\/strong>, it will open an interactive finder; reads the list of files from\u00a0<strong>stdin<\/strong>, and writes the selected item to\u00a0<strong>stdout<\/strong>.<\/p>\n<p>Simply type the name of the file you are looking for in the prompt. When you find it, click enter and the relative path of the file will be printed to\u00a0<strong>stdout<\/strong>.<\/p>\n<pre>$ fzf\r\n<\/pre>\n<div id=\"attachment_30994\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/fzf-prompt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30994\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/fzf-prompt.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/fzf-prompt.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/fzf-prompt-768x548.png 768w\" alt=\"Fzf Prompt\" width=\"802\" height=\"572\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Fzf Prompt<\/p>\n<\/div>\n<p>Alternatively, you can save the relative path of the file your are searching, to a named file and view the content of the file using a utility such as\u00a0<a href=\"https:\/\/www.tecmint.com\/13-basic-cat-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">cat command<\/a>\u00a0or\u00a0<a href=\"https:\/\/www.tecmint.com\/bat-a-cat-clone-with-syntax-highlighting\/\" target=\"_blank\" rel=\"noopener\">bcat<\/a>.<\/p>\n<pre>$ fzf &gt;file\r\n$ cat file\r\nOR\r\n$ bat file\r\n<\/pre>\n<p>You can also use it in conjunction with the\u00a0<a href=\"https:\/\/www.tecmint.com\/35-practical-examples-of-linux-find-command\/\" target=\"_blank\" rel=\"noopener\">find command<\/a>, for example.<\/p>\n<pre>$ find .\/bin\/ -type f | fzf &gt;file\r\n$ cat file\r\n<\/pre>\n<h3>How to Use Fuzzy Completion in Bash and Zsh<\/h3>\n<p>To trigger fuzzy completion for files and directories, add the\u00a0<code>**<\/code>\u00a0characters as a trigger sequence.<\/p>\n<pre>$ cat **&lt;Tab&gt;\r\n<\/pre>\n<div id=\"attachment_30995\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/auto-completion-of-filenames.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30995\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/auto-completion-of-filenames.png\" alt=\"Auto Completion of Filenames\" width=\"752\" height=\"249\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Auto Completion of Filenames<\/p>\n<\/div>\n<p>You can use this feature while working with environmental variables on the command-line.<\/p>\n<pre>$ unset **&lt;Tab&gt;\r\n$ unalias **&lt;Tab&gt;\r\n$ export **&lt;Tab&gt;\r\n<\/pre>\n<div id=\"attachment_30996\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/auto-completing-env-varibales-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30996\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/auto-completing-env-varibales-in-Linux.png\" alt=\"Auto Completing Env Variable in Linux\" width=\"552\" height=\"230\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Auto Completing Env Variable in Linux<\/p>\n<\/div>\n<p>The same applies to the\u00a0<strong>ssh<\/strong>\u00a0and\u00a0<strong>telnet<\/strong>\u00a0commands, for auto-completing host names that are read from the\u00a0<strong>\/etc\/hosts<\/strong>\u00a0and\u00a0<strong>~\/.ssh\/config<\/strong>.<\/p>\n<pre>$ ssh **&lt;Tab&gt;\r\n<\/pre>\n<div id=\"attachment_30997\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/auto-completing-hostnames-ssh-command.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30997\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/auto-completing-hostnames-ssh-command.png\" alt=\"Auto Completing Hostnames\" width=\"552\" height=\"230\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Auto Completing Hostnames<\/p>\n<\/div>\n<p>It also works with the\u00a0<a href=\"https:\/\/www.tecmint.com\/kill-processes-unresponsive-programs-in-ubuntu\/\" target=\"_blank\" rel=\"noopener\">kill command<\/a>, but without the trigger sequence as shown.<\/p>\n<pre>$ kill -9 &lt;Tab&gt;\r\n<\/pre>\n<div id=\"attachment_30998\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/auto-completion-for-kill-command.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30998\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/auto-completion-for-kill-command.png\" alt=\"Auto Completion for Kill Command\" width=\"752\" height=\"306\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Auto Completion for Kill Command<\/p>\n<\/div>\n<h3>How to Enable fzf as Vim plugin<\/h3>\n<p>To enable\u00a0<strong>fzf<\/strong>\u00a0as a vim plugin, append the following line in your Vim configuration file.<\/p>\n<pre>set rtp+=~\/.fzf\r\n<\/pre>\n<p><strong>fzf<\/strong>\u00a0is being actively developed and can be easily upgraded to latest version using following command.<\/p>\n<pre>$ cd ~\/.fzf &amp;&amp; git pull &amp;&amp; .\/install\r\n<\/pre>\n<p>To see the complete list of usage options, run\u00a0<strong>man fzf<\/strong>\u00a0or check out its Github Repository:\u00a0<a href=\"https:\/\/github.com\/junegunn\/fzf\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/github.com\/junegunn\/fzf<\/a>.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/the-silver-searcher-a-code-searching-tool-for-linux\/\" target=\"_blank\" rel=\"noopener\">The Silver Searcher \u2013 A Code Searching Tool for Programmers<\/a><\/p>\n<\/div>\n<p><a href=\"https:\/\/www.tecmint.com\/fzf-fuzzy-file-search-from-linux-terminal\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fzf\u00a0is a tiny, blazing fast, general-purpose, and cross-platform command-line fuzzy finder, that helps you to search and open files quickly in Linux and Windows operating system. It is portable with no dependencies and has a flexible layout with support for Vim\/Neovim plugin, key bindings, and fuzzy auto-completion. The following GIF shows how it works. To &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/11\/fzf-a-quick-fuzzy-file-search-from-linux-terminal\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Fzf \u2013 A Quick Fuzzy File Search from Linux Terminal&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11200","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11200"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11200\/revisions"}],"predecessor-version":[{"id":11201,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11200\/revisions\/11201"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}