Live data from Hacker News

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

andrew-quinn.me

131–140 of 292 posts

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

#131
post #38

Earlier quoted context omitted.

The default install script asks if you want to install key bindings and adds that to your bashrc. How did you install fzf?

apt install? There's no way I'm integrating a core tool like that with a crude "curl | zsh" hack. How and when would it get updated? Am I expected to stick that in an Ansible playbook?

A shoutout to home-manager, where it's just programs.fzf.enableBashIntegration = true;

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

#133

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…

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…

Issues like this are why I write everything into scripts and pipelines, even the munging. This way everything is documented: the environment, the input, the output, the log file, what ran, and longform comments with why I was doing it.

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

#134
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
  }

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

#135

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 hope this article along with this comment serves as a gateway drug for people to realize fzf is also really useful in injecting some interactivity into their shell scripts. It feels different to write scripts which call down fzf from the heavens for a split second.

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

#136
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…

agreed. preview rips

i was confused how to adjust the width and figured it out, here’s where i asked, learned, and shared my figlet script

fzfont

https://github.com/junegunn/fzf/discussions/3211

https://asciinema.org/a/grALSk2M1tkVPiiyrAGCbdX5J (without width adjustment iirc)

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

#137
I'd never heard of fzf before! It looks like there's a lot of cool stuff you can do with it, but honestly, I think it's worth it even just to replace the frustrating ctrl+R search in bash, which I use a lot, but constantly dislike.

I feel like with a lot of these kinds of tools, if I have to actually actively use them, I forget that they exist ('z'[0] ended up being like this for me) and eventually remove them, but something that directly replaces something I use regularly (but hate the UX of) is perfect for me.

Another bit that helps is that I'm not having to learn/remember something new that I'll only have on my laptop. I'll continue to ctrl+R and get a nicer experience, but if I'm ssh'ed into some random box without fzf, ctrl+R will still work, just with a worse experience.

[0] https://github.com/rupa/z

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

#138
I've got a couple git aliases that are nice.

Use tab to select multiple git branches that are deleted when you hit enter

alias gbD="git for-each-ref --format='%(refname:short)' refs/heads | fzf -m | xargs git branch -D"

Lists git branches and checkouts the selected

alias gcof="git for-each-ref --format='%(refname:short)' refs/heads | fzf | xargs git checkout"

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

#139
post #133

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…

Issues like this are why I write everything into scripts and pipelines, even the munging. This way everything is documented: the environment, the input, the output, the log file, what ran, and longform comments with why I was doing it.

Good choice but that for me breaks the "carpe Diem" part of the inspiration that can go away in a whim, that it's what I have when I'm writing (complex) one liners in the shell.

Or maybe I'm just lazy.

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

#140

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...
Post reply on HN