Live data from Hacker News

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

andrew-quinn.me

181–190 of 292 posts

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

#182

Earlier quoted context omitted.

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.

fzf includes the path in your match. So, unless the directories also have unpractical names, this typically won’t be a problem.

Learning for me: Brew suggests to install the shortcuts but doesn’t automatically do this. Just activated this and Ctrl-R is a big improvement this way.

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

#183

Earlier quoted context omitted.

Something I've always wanted from my shell history is to be able to record relative filepaths as their absolute equivalent in the history, is that supported in atuin?. If you do a lot of data munging on the CLI, you end up with a lot of commands like `jq 'complicated_selector' data.json`, which if I want to remember the selector is good, but if I want to remember which data I ran it on is not so good. I could do it w…

I sometime use a #a-text-comment at the end of long/complex command line incantation. Easy to find using fzf at a later date. Also can provide you with a quick context.

This is commonly referred to as a 'bashtag'

Or at least I hope it is. :)

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

#184

> I reviewed my options. I could > Use my half-remembered knowledge of the FHS to guess around, with trees and greps, or > Just know and commit it to memory and feel superior to everyone else, or > Just pipe find . ‘/’ to fzf and start searching. Or you could have just typed find / -name nginx.conf Maybe an extra 2>/dev/null if you dont want to do it from sudo

Notice in that section I called it within a subshell. If I ran `vi $(find / -name nginx.conf)`, and there happened to be multiple files named nginx.conf lying around my system, my guess is `vi` would try to open all of them as different buffers, which is not generally what I want.

Is tab-typing vi /etc/nginx/nginx.conf by hand really that much extra effort?

Or, for this specific example, remember standard config file convention?

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

#185

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 }

I like ` `; ctrl-t opens fzf and pastes any selected files onto the command line. If you choose to abort you end up back at the prompt after ` `.

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

#186
post #118
post #72

I don't think this article goes far enough into what a game-changer fzf can be. Combined with some clever "preview" functions, and a pop-up terminal function (which, that part is admittedly harder than it ought to be) it can be an across the board a better general purpose script menu creator than most command line AND GUI tools, namely due to - instant previews AND - the ability to either arrow up and down OR fuzzy t…

I have ~200 lines of scripts that use fzf and mblaze ( https://github.com/leahneukirchen/mblaze ) as the ui for my very own mua. It's all Unixy and lovely. I should write a page about that

Yes please! Even just posting some of the scripts somewhere would be awesome. I'm always looking for better ways to handle email. Mblaze seems great, but I've never managed to quite tap into it's obvious power.

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

#187
post #180

Earlier quoted context omitted.

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 h…

There’s no real good mechanism for what fzf is trying to do. profile.d might work, but I think that is more intended for environment variables, rather than interactive shell changing scripts.

There’s no standardised way to extend interactive shell configuration without just appending to /etc/bashrc.

The other problem with this is that it is hard to disable. What if you want fzf but without the key bindings? FZF could add a mechanism for this, but it doesn’t fully solve the problem, because the FZF script being added to global configuration will always be run before any user config.

In this specific case, it is a limitation of bash (and probably ZSH as well) that there is no simple package-manger compatible extension mechanism for interactive shell plugins which doesn’t sacrifice user control.

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

#188

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?

Looks like it is still down - but see eg: https://askubuntu.com/questions/67283/is-it-possible-to-make...

To wit:

> It says to put those commands in the .bashrc config:

    shopt -s histappend
    PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
> The first command changes the history file mode to append and the second configures the history -a command to be run at each shell prompt. The -a option makes history immediately write the current/new lines to the history file.

I used to have something like this set up on my Linux laptop - the downside is that seperate shell/terminals/windows/tabs don't keep seperate history - so if you eg start a server in shell one (rails s), start editor in two - then go back to one and ctrl-c out - up arrow will now give you "vim" not "rails s".

The problem compounds if you ping, or curl in another shell etc.

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

#190

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...

This is literally going to change my life! T_T
Post reply on HN