Live data from Hacker News

So you've installed `fzf` – now what?

andrew-quinn.me

41–50 of 292 posts

Re: So you've installed `fzf` – now what?

#41

Am I the only one that tried fzf as a replacement to the default Ctrl+R behavior, then switched back? I'm perfectly satisfied with the default Ctrl+R functionality, to the point that fzf seemed to add visual clutter without any value. I guess I was never let down by inverse search. Context: I'm using Linux and doing SWE and SRE work, and constantly live in the terminal.

The default ctrl+r behavior doesn't allow me to scroll up through my history of matches, which is always disappointing. Often it's some random incantation I'm trying to search for that shares a prefix with other more common commands and the default ctrl+r requires me to type out far enough to be unique, which defeats the purpose of history search. Maybe I'm missing some essential behavior that I'm not familiar with.

I don't know if the version I have is somewhat special, but I can simply keep pressing ctrl+r to search "up" for the next match.

So, type: ctrl+r, prefix, and then keep pressing ctrl+r to find everything that matches the prefix.

Re: So you've installed `fzf` – now what?

#42
I have ctrl-r and alt-c assigned to macro keys on my keyboard, they're so danged useful.

Something else you can try in your `~/.gitconfig`

    [alias]
      fza = "!git ls-files -m -o --exclude-standard | fzf -m --print0 | xargs -0 git add"

    git fza will quickly let you add files if you've changed a lot.
I alias `git fza` to `ga` and it gets used a lot

Oh, and another useful shortcut is this:

    export FZF_CTRL_T_COMMAND="mdfind -onlyin . -name ."
Obviously only useful for MacOS, but fzf plus spotlight is pretty useful. You can use it to find that lost file that you only remember part of the name!

Re: So you've installed `fzf` – now what?

#44
post #19

I love how people share their fzf scripts whenever a new post comes along. I'll share some of my own. First, some env variables for setting defaults: export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git' export FZF_DEFAULT_OPTS='--layout=reverse --inline-info' export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" And some neat commands: 1. A command for fuzzy jumping between workspaces with tree previews (depen…

That AWS logs one is fantastic.

Re: So you've installed `fzf` – now what?

#45
have no need for this, plenty fast without it. these two have been sufficient for all my needs:

ctrl + r for most things

history | grep for searching when i forget the exact command or want to see related commands.

I don't want pull downs, pull ups, drop downs, expanded hamburger menu, hot dogs, another set of key strokes to remember how i started some service last month.

Re: So you've installed `fzf` – now what?

#46

We have an IoT command server and connecting to one of the devices (for maintenance, logs or whatever) involved two manual lookups in the output of two commands and then finding your match in both. I was sick of this one day and with some grep, sed, awk and finally fzf, you could just sort of type the device's name and press "enter" to connect. People's reaction when I showed them was basically WHAT IS THIS MAGIC?!?

This is fantastic - I'm in a similar situation, and just threw together a quick FZF incantation to look up a device's ID for use in other commands.

Re: So you've installed `fzf` – now what?

#47
I've been using fzf for a long time, but I didn't even know about Ctrl-R. Since I use fish, I've been used to just typing some random part of an old command, then hitting the Up key to cycle through old commands with that snippet. I'm going to have to give this a real shot.

Re: So you've installed `fzf` – now what?

#48

Fantastic article. I was exactly in the situation the article describes, I installed it, then, didn't find a use case. But that's because Ubuntu doesn't come with completion enabled by default. You have to add in your bashrc: if [ -e /usr/share/doc/fzf/examples/key-bindings.bash ]; then source /usr/share/doc/fzf/examples/key-bindings.bash fi The fzf and ubuntu docs don't mention you have to. Couldn't find easily how…

Strictly speaking the ubuntu/debian docs do mention it, but yeah its not super discoverable: https://salsa.debian.org/go-team/packages/fzf/-/blob/master/...

Re: So you've installed `fzf` – now what?

#49

Am I the only one that tried fzf as a replacement to the default Ctrl+R behavior, then switched back? I'm perfectly satisfied with the default Ctrl+R functionality, to the point that fzf seemed to add visual clutter without any value. I guess I was never let down by inverse search. Context: I'm using Linux and doing SWE and SRE work, and constantly live in the terminal.

Imagine you have a bunch of different for loops and you want to get the one that ran a specific command. You can use something like "history | grep for | grep command" or you can use fzf. Ctrl-r, type "f o r " then type "c o m m" and you'll quickly narrow down the search results.

It's the fuzziness that really beats ordinary ctrl-r, being able to search on multiple fragments of text is just fantastic.

Re: So you've installed `fzf` – now what?

#50
I’ve never used fzf before and live in a shell all day, but the capabilities shown in the article doesn’t seem very useful to me. Am I missing something?

For Ctrl+R, how many times are people running similar variants of commands that they 1) don’t know what they typed and 2) didn’t think to simplify their workflow to not be running duplicated commands?

For Alt+C, are peoples’ file and directory layouts such a mess that they need to search entire directory trees to find what they’re looking for?

I’m confused.

Post reply on HN