Live data from Hacker News

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

andrew-quinn.me

171–180 of 292 posts

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

#171

Earlier quoted context omitted.

Fuzzy history is nice, but the real game changer for me was the ability to pretty much stop remembering paths in big projects. The default keybindings provide the Ctrl-T shortcut to insert a path/filename on the command line using fuzzy search and Alt-C to fuzzy-cd. No more tedious completion - just search + enter.

Same thing with Emacs with Projectile. I can't believe people still using a tree view of a deeply nested project and clicking though directories and finally finding a file. I am not willing to type more than a few characters for any file in the project. Fuzzy finding with quick narrowing FTW.

I've seen a number of projects with hundreds of "index.js" files.

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

#172

I really like the suggested command ` $(fzf)` to quickly open files in relative to the directory I am in. However, when I abort the fuzzy find with esc, it still opens without a file input, which is not what I want, so I wrote a little script for my shell config to prevent this: fuzz() { file=$(fzf) if [ ${#file} -gt 0 ]; then nvim "$file" # or any editor you prefer else : fi }

It returns non-zero exit codes when there are no matches or no selections made, so you can shorten that:

  fuzz() { file=$(fzf) && nvim "$file"; }

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

#173
post #89

Interesting, I'm of the first kind, who uninstalled it quickly. I use ctrl-r a lot, though I have no issue remembering exact portions of the commands, but that may just be me. I'll give it another try. In the same vein as ripgrep (rg), I recommand the author (and everybody else) to give fd-find (fd) a try as a replacement to find. It's much, much faster (multithreaded search), and has better defaults to use from the…

if the article is saying to use 'fzf' to fuzzy-find things, why do we want to install 'fd' to multi-thread find things alongside fzf ?

nvm. tutorial explains https://youtu.be/qgG5Jhi_Els?t=400

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

#174
post #110

Maybe I'm just getting old, but I found most of the animations in this article to go too fast. I couldn't tell what was happening, couldn't tell what I was supposed to be looking at.

> Maybe I'm just getting old, but I found most of the animations in this article to go too fast.

It's not that you're getting old and it's not that it's "too fast". The problem with many animations like this and why they make no sense whatsoever is because they cycle without adding a little pause... So you have no way to know when it's beginning and when it's ending. It's endemic on Github.

Some .gif files are properly done but IMO most don't explain anything, only add confusion and would be better served by three or four screenshots.

There are poor UX and then there are these kind of cycling .gif files.

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

#175

Earlier quoted context omitted.

If that's your use case, here's another game changer (one line bashrc change to make bash_history changes immediately, rather than upon shell exit, e.g. when you end your tmux session): https://web.archive.org/web/20090815205011/http://www.cuberi...

FWIW I get a 503 on that URL. Any chance someone can give me that magic one-liner?

Not sure what that link had as it's dead for me as well but...

PROMPT_COMMAND='history -a'

Has always worked for me. Goes in your .bashrc from the FM

PROMPT_COMMAND ¶ If this variable is set, and is an array, the value of each set element is interpreted as a command to execute before printing the primary prompt ($PS1). If this is set but not an array variable, its value is used as a command to execute instead.

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

#176

The interface is really cool. But is it possible to globally set the default "fuzziness" to zero? I'd like to get only exact matches in all circumstances.

Add this to your login script:

  export FZF_DEFAULT_OPTS="--exact"
Or invoke it with one of these:

  fzf --exact
  fzf -e
Or if you start your search with a single quote ' it disables fuzz. (But maybe you already knew that, it sounds like you want the first option.)

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

#177

I love fuzzy shell history. Game changer in terms of shell productivity. I use atuin[0] instead of fzf as I find the experience a bit nicer and it has history backups built in (disclaimer, I am a maintainer) Some of our users still prefer fzf because they are used to how it fuzzy finds, but we're running an experiment with skim[1] which allows us to embed the fuzzy engine without much overhead - hopefully giving them…

If that's your use case, here's another game changer (one line bashrc change to make bash_history changes immediately, rather than upon shell exit, e.g. when you end your tmux session): https://web.archive.org/web/20090815205011/http://www.cuberi...

for zsh

    setopt inc_append_history

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

#178

Earlier quoted context omitted.

Thank you!! Why on earth isn't that the default. It always seemed weird that with multiple bash windows open, the commands from most of them weren't added to the history.

My guesses are that it's on-close so you can follow the per-shell history slightly easier (rather than it being interleaved from multiple shells?), or reducing disk writes?

They don’t interlace which can be nice

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

#179

> And I found myself asking: Where the heck is nginx.conf? The author lists some ways but misses the standard Unix way: simply use locate https://en.m.wikipedia.org/wiki/Locate_(Unix) Using locate maybe piped to grep is good enough for all my finding needs

Don't you need admin to run `updatedb`? On a work machine, this is my main barrier to using plocate.

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

#180

Earlier quoted context omitted.

Yes. It's a shell hook, it's expected for you to add it to your bash/zsh .rc yourself. How else can it work?

Packages can place init scripts into /etc/profile.d and those get autoloaded by shells.

This is what happens when tooling providers try to do their own packaging. Homebrew, apt, rpm, and other package managers, as well as bash, zsh and other shells, all offer standardized ways to install configuration loader scripts for the user's environment, and to display installer messages that prompt the user to do it - but fzf has a bunch of functionality to go around all that and auto-update itself in place and hack lines into the user's bashrc/zshrc.

Not trying to single out fzf here - there are many other tools that do this - but I find this behavior really sad because it makes me very disinclined to trust the tool with anything. A command-line tool should not be trying to auto-update itself or manipulate dotfiles in the user's home directory. It's dangerous and unexpected.

Post reply on HN