DEV Community

Cover image for Integrating TLDR with FZF
Helder Burato Berto
Helder Burato Berto

Posted on • Originally published at helderberto.com

Integrating TLDR with FZF

In this post, we gonna dive into TLDR with fzf search.

Usage of TLDR

Go to your favorite terminal, with TLDR enabled, and execute the following command:

$ tldr brew
Enter fullscreen mode Exit fullscreen mode

Searching with FZF

$ fzf .
Enter fullscreen mode Exit fullscreen mode

It will execute a fuzzy search in the current directory.

Passing a TLDR list to FZF

$ tldr --list | fzf
Enter fullscreen mode Exit fullscreen mode

The first argument tldr --list will generate a list of available commands enabled in your command line.

And when passing with a pipe operator | it will send the results to fzf.

Selecting an Argument with FZF

$ tldr --list | fzf | xargs tldr
Enter fullscreen mode Exit fullscreen mode

As you did in the previous step, it will share the list to fzf, and when you select an option it will send the argument via xargs to execute with tldr.

Previewing Commands on Searching

It creates a preview window, showing the results from TLDR and passing to the new window via xargs.

Let's try with the following command:

$ tldr --list | fzf --preview "tldr {1}" --preview-window=right,60% | xargs tldr
Enter fullscreen mode Exit fullscreen mode

Bonus: Aliasing

Create an alias to avoid remembering all this stuff:

alias tldrf='tldr --list | fzf --preview "tldr {1}" --preview-window=right,60% | xargs tldr'
Enter fullscreen mode Exit fullscreen mode

Source your command line configuration file, in my case it is .zshrc, and voilá!

Try your new alias into the command line:

$ tldrf
Enter fullscreen mode Exit fullscreen mode

Top comments (0)