5 ms·
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
by BiteCode_dev 4y ago
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 to do it with google, but chatgpt saved the day once again.
- triyambakam 4y agoThe default install script asks if you want to install key bindings and adds that to your bashrc. How did you install fzf?
- sickmartian 4y agoNot parent but on pop-os, using sudo apt install zfz I got the same behavior, had to add it myself to .bashrc
- acka 4y agoPretty much par for the course, Linux distributions don't do per user configuration of tools beyond appending to PATH or setting some essential environment variables using scripts in in /etc/profile.d/. They will most certainly not mess with login scripts.
- sophacles 4y agoYeah sure, that makes sense. I'm surprised that the .deb doesn't install the stuff from `$upstream/shell` into `/usr/share/fzf` though. That's the sort of thing `/usr/share/$prog` is intended for. Then it would just be (in bash anyway): source /usr/share/fzf/keybindings.bash
- farnerup 4y agoIn debian: source /usr/share/doc/fzf/examples/completion.bash source /usr/share/doc/fzf/examples/key-bindings.bash
- Steltek 4y agoapt 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?
- tough 4y agohttps://github.com/gantsign/ansible-role-oh-my-zsh https://github.com/gantsign/ansible-role-oh-my-zsh https://github.com/dotstrap/ansible-fzf https://github.com/dotstrap/ansible-fzf I don't see why not
- stevenhuang 4y agoYes. It's a shell hook, it's expected for you to add it to your bash/zsh .rc yourself. How else can it work?
- Steltek 4y agoFor an article titled "You've installed fzf. Now what?", I would've expected step 1 to be "how to add the shell hook for your particular shell". Especially since people here are referencing extra integrations that the bundled shell hook doesn't setup.
- 5e92cb50239222b 4y agoPackages can place init scripts into /etc/profile.d and those get autoloaded by shells.
- ak217 4y agoThis 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.
- zokier 4y agoStrictly speaking the ubuntu/debian docs do mention it, but yeah its not super discoverable: https://salsa.debian.org/go-team/packages/fzf/-/blob/master/debian/README.Debian# https://salsa.debian.org/go-team/packages/fzf/-/blob/master/...
- AiAi 4y agoThanks fore sharing. I was also lost reading this article, because I installed with apt (Debian). After searching for "fzf + Ctrl+R" I found about the keybindings part.
- mlegendre 4y agoThis enables the C-r / M-c / C-t key bindings, but there's also a completion.bash file. This enables the "**" completion trigger, which can contextually complete paths, envvar names or PIDs in commands. (See "Fuzzy completion for bash and zsh" in fzf's readme [1]). Similarly, you can add to your .bashrc: if [ -e /usr/share/doc/fzf/examples/completion.bash ]; then source /usr/share/doc/fzf/examples/completion.bash fi /usr/share/doc/fzf/README.Debian explains this, as well as the setup for zsh, fish and vim. [1]: https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh https://github.com/junegunn/fzf#fuzzy-completion-for-bash-an...
- b3morales 4y agoYou do have to remember to use it, but the thing to keep in mind is that you can pipe a list of ANYTHING into it. Any list of text items you can search through with a text query is fair game. git log --oneline | fzf for example is one of my favorite tricks. Instead of scanning by eye or repeatedly grepping to find something, it's a live fuzzy filter. And depending on how deep you want to go you can then add key bindings to check out the selected commit, or preview the full message, or anything really.
- bardan 4y agoAnd don't forget that your selection is printed to stdout: git log --oneline | fzf | cowsay Sky's the limit.