I love fzf for one-liners. Simple pattern: a command gives you everything, pipe it to fzf so that you can pick one, then pipe that to a command to switch to it. alias kctx='kubectl config get-contexts -oname | fzf | xargs kubectl config use-context' alias prv="gh pr list | fzf | awk -F ' ' '{print $1}' | xargx gh pr view -w" Amazing stuff.
So you've installed `fzf` – now what?
241–250 of 292 posts
Re: So you've installed `fzf` – now what?
#242I 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...
So, you revisit a window, and you want to start from where you left, but now, you might maybe wade through 100's of commands before you get back to that point in time. There are fixes for this too of course, my point is, that it doesn't come without side effects, and that is maybe why it isn't set as default behaviour. At least in a pre 'fzf/atuin/smenu' world.
I prefer smenu's history search, even if I consider myself a heavy fzf user.
Re: So you've installed `fzf` – now what?
#243Earlier quoted context omitted.
I often have three or more terminals open, doing different tasks in each; I also often have cycles of work where I'll repeat the last three commands again (three up-arrows and a return). This breaks if one terminal's commands get inserted into another terminal's history.
Comment from the author: "Ted, the change I suggest doesn't affect the independence of your sessions as you suggest. Each shell maintains a unique history in memory so modifying the history file has no affect on running terminals. The only time the history file is read is when you start a new terminal. I recommend you try my suggestion. Really, all I am doing is eliminating the race condition that causes the bash his…
If you do want to load the history persisted from other shells into the current one, all you have to do (if memory serves) is:
$ history -rRe: So you've installed `fzf` – now what?
#244I love fzf for one-liners. Simple pattern: a command gives you everything, pipe it to fzf so that you can pick one, then pipe that to a command to switch to it. alias kctx='kubectl config get-contexts -oname | fzf | xargs kubectl config use-context' alias prv="gh pr list | fzf | awk -F ' ' '{print $1}' | xargx gh pr view -w" Amazing stuff.
alias prlsf="GH_FORCE_TTY=yes gh pr list | fzf --ansi --header-lines 3 --preview 'GH_FORCE_TTY=yes gh pr view {1}' | awk '{ print \$1}' | xargs -I {} gh pr view --web {}"Re: So you've installed `fzf` – now what?
#245> 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
Too often do I ssh into some ECS, run a docker or whatever, only to find it doesn't have locate.
The problem then is that even if you can quickly install it, it'll still need to reindex the whole system, which may take minutes (and can easily cause stressed servers to start trashing).
If it ain't there -and it often is- getting it is a lot of hassle.
Re: So you've installed `fzf` – now what?
#246Earlier quoted context omitted.
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. :)
but that isn't sexy somehow. we'll have to settle on 'shag'.
Re: So you've installed `fzf` – now what?
#247Maybe 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.
An animation that shows a very slow pace might communicate that the tool is slow too.
Re: So you've installed `fzf` – now what?
#248I 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 }
vim $(fzf)
but don't press enter. Press tab instead. The shell will expand the $(), which will run fzf and let you choose a file. When you've made your choice, fzf will exit, and your choice will be written in place of the $(), so you can see the result before you run it. It works with any command, not just vim. It's particularly useful when doing multi-selects. And if you press ESC then nothing gets written.I've only tested this with zsh, not sure how other shells behave. And you may need to alter fzf's default command or pipe something into it.
Re: So you've installed `fzf` – now what?
#249I’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 th…
Re: So you've installed `fzf` – now what?
#250Earlier 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.
I've got this in my profile: export CDPATH="$HOME:$HOME/code/:$(ls -d $HOME/work/*/| tr \\n :)" so regardless of my cwd I can cd into pretty much any project I'd want to.
~/project% find -type d | wc -l
13946
I access files in a dozen or so folders in this hierarchy regularly, so fuzzy find is an extreme boost for me.