19 ms·
So you've installed `fzf` – now what?
- renewiltord 4y agoI have `,fv` running `nvim $(fzf)` and it's actually a little annoying because afterwards I can't find the filename that I had open. I wish there were some way to expand it into my history.
- themadsens 4y agoYou can: Help for bash 'history -s args': The args are added to the end of the history list as a single entry
- renewiltord 4y agoThank you. I must find the equivalent zsh command.
- agumonkey 4y agodont forget ` -m` for multiselect ;)
- ww520 4y agoQuick question. How do you set up the key bindings for the command prompt window on Windows? The control-r, alt-c, etc.
- thunderbong 4y agoIn my PowerShell profile I have the following - Remove-PSReadlineKeyHandler 'Ctrl+r' Remove-PSReadlineKeyHandler 'Ctrl+t' Import-Module PSFzf All other shortcuts worked out of the box!
- BeetleB 4y agoI use xonsh on Windows, and set up the keybindings there. It, frankly, is messy to do so in xonsh.
- atemerev 4y agoSo, just like what fish shell gives out of the box :)
- wkdneidbwf 4y agoi love and daily-drive fish, but i don’t think fish does everything fzf does. did you stop reading the article at ctrl-r?
- mattgreenrocks 4y agoI like this: https://github.com/PatrickF1/fzf.fish https://github.com/PatrickF1/fzf.fish It's one of the few packages that I think genuinely enhance fish versus merely adding a bunch of cruft.
- petepete 4y agoThat's still the only fish plugin I have installed. alt+ctrl+f and ctrl+r are indispensable.
- streb-lo 4y agoI'm a recent fish convert (from zsh) and I love it. The only thing that annoys me is working with Android AOSP requires sourcing a bunch of bash functions that I don't feel like porting to fish so I'm occasionally required to drop into bash whereas with zsh and it's POSIX compatibility I could just source the bash functions and it would work fine. But fish's completions work much better out of the box and they have some useful features like being aware of your history in each directory.
- rjzzleep 4y agofzf actually has a huge list of functions for the shell to use on their wiki https://github.com/junegunn/fzf/wiki/examples https://github.com/junegunn/fzf/wiki/examples
- jraph 4y agoI've been seeing mentions of fzf for some time but this article might make it try it. Zsh's H-S-MW plugin [1], which provides multi word CTRL+R to search the history + a couple of half-assed tools I wrote [2] seem to cover most of the think I would need fzf for, but maybe fzf would work better or be a useful addition to my toolset. Maybe it could replace those half-assed tools. Of course I intensively use ripgrep. [1] https://github.com/z-shell/H-S-MW https://github.com/z-shell/H-S-MW [2] https://news.ycombinator.com/item?id=34495070 https://news.ycombinator.com/item?id=34495070
- djcannabiz 4y agoThat blew my mind, thanks so much for sharing
- Yoofie 4y agoSo I might aswell ask here: I want to search for a string using ripgrep, select one of the files from the result list using FZF and then open the selected file with VS code. > rg . | fzf How do I do this on windows (NOT Linux)?? *Note:* Assume I already have ripgrep, FZF & VS Code installed.
- thunderbong 4y agoThe exact same command worked for me on Windows in PowerShell! In fact, I went and tried the other shortcuts and they worked as well e.g. Alt+C Didn't know about this all this while and I had fzf installed!
- Joker_vD 4y agoYou open Total Commander in that folder, press Alt+F7, put your string into the lower search box and press search. It will give you the list of matching files, with F3 available for quick preview; then you right click the file you need and choose "Open with VS Code" from the context menu. Sadly, you don't get the "context" (the content of actual matches) out of the box, you'll have to resort to double-tapping F3 while manually going down the file list. That's a downside, I fully admit that.
- Yoofie 4y agoI appreciate your answer but the whole point is to do everything from the command line. If I need to use another application, I can just open VS Code in the directory and search from there directly. In the article, they provide this: >rg . | fzf | cut -d ":" -f 1 What would be the easy windows equivalent of > cut -d ":" -f 1 ??
- spapas82 4y agocut is a part of git for windows. It should be inside "c:\Program Files\Git\usr\bin\" folder. So after adding this folder to your path `rg . | fzf | cut -d ":" -f 1` should work. However I wasn't able to actually use that to open that file in vscode or vim because the application started immediately without waiting to pick a file ...
- 1-more 4y agoTwo things I use fuzzy finder for: 1. flog: go to git branches I had checked out in the past quickly 2. pr: preview and check out PRs I've been assigned to review flog () { branch="$( git branch --sort=-committerdate --format="%(committerdate:relative)%09%(refname:short)%09%(subject)" \ | column -ts $'\t' \ | fzf \ | sed 's/.*ago \+\([^ ]*\) .*/\1/' )" git co $branch || ( echo -n "git co $branch" | pbcopy ) } errcho() { echo "$@" 1>&2 } jq_query=$(cat <<- EOF map( { key: "\(.number)" , value: { line: "\(.number):\(if .isDraft then "" else " " end):\(.author.login):\(.title):\(.headRefName)" , body: "# \(.number): \(.title) ## \(.headRefName) \(.body)" } } ) | from_entries EOF ) pr () { local gh_user=${1:-} if [ -z "$gh_user" ]; then gh_user="@me" fi tmpFile=$(mktemp /tmp/prs-XXXXXX.json) cleanup () { rm "$tmpFile" } trap cleanup EXIT gh pr list -S "review-requested:${gh_user}" \ --json number,title,headRefName,body,author,isDraft \ | jq -r "$jq_query" > "$tmpFile" preview_command="\ jq -r '.[\"{1}\"].body' $tmpFile \ | pandoc -f gfm -t markdown \ | glow -s light - " pr_number=$( jq -r \ 'to_entries | map(.value.line) | join(" ")' \ "$tmpFile" \ | column -t -s: \ | fzf \ --ansi \ --delimiter=' ' \ --preview="$preview_command" \ --preview-window=up:80% \ | grep -o '^[0-9]\+' ) if [ -n "$pr_number" ]; then errcho "checking out #$pr_number" gh pr checkout "$pr_number" && gh pr view --web "$pr_number" && git pull || echo -e "gh pr checkout $pr_number && gh pr view --web $pr_number && git pull" else errcho "canceled" fi }
- unit_circle 4y agoNice. I'm going to dig through these tomorrow. Thanks for posting! The PR review helper looks excellent and I'm excited to try it out. Til about `pandoc` and `glow`. I whipped up a nice, performant branch picker last night that I'm pretty happy with, hopefully there are some useful tidbits for others. It's similar to your `flog` command but it uses the reflog to find the most recently checked out branches. It filters those which have been deleted using a set structure (well, map of bools), thus requiring BASH 4+. I'll be interested to see the differences in behavior and performance of your approach https://gist.github.com/pnovotnak/4dfe9b2867bf6fea60fa94b4c8a2cc9d https://gist.github.com/pnovotnak/4dfe9b2867bf6fea60fa94b4c8...
- BiteCode_dev 4y agoFantastic 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
- _aqmj 4y agoI had no idea about alt+c, that's a game changer for me. great intro.
- itchynosedev 4y agoYou can also go to the specific line you pick from fzf search nvim $(rg . --vimgrep | fzf | awk -F: '{print $1, "+" $2+0}')
- calmoo 4y agofzf is super useful for navigating and switching git branches I realised today [1] function gbll(){ local tags branches target branches=$( git --no-pager branch --sort=-committerdate \ --format="%(if)%(HEAD)%(then)%(else)%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%1B[0;34;1mbranch%09%1B[m%(refname:short)%(end)%(end)" \ | sed '/^$/d') || return tags=$( git --no-pager tag | awk '{print "\x1b[35;1mtag\x1b[m\t" $1}') || return target=$( (echo "$branches"; echo "$tags") | fzf --no-hscroll --no-multi -n 2 \ --ansi --preview="git --no-pager log -150 --pretty=format:%s '..{2}'") || return git checkout $(awk '{print $2}' <<<"$target" ) } [1]https://github.com/junegunn/fzf/wiki/Examples#git https://github.com/junegunn/fzf/wiki/Examples#git
- kbd 4y agoAgree I use fzf extensively in my git aliases: https://github.com/kbd/setup/blob/master/HOME/.config/git/config https://github.com/kbd/setup/blob/master/HOME/.config/git/co... Perfect example: my "cherry pick" alias: cp = !git pick-branch | xargs git pick-commits | tac | xargs -t git cherry-pick Those "pick-" aliases pop up fzf to let me choose a branch, then commits to cherry pick. No more copying hashes anywhere. Similarly, my alias for git add lets me fzf-select a list of files to stage based on what "git status" reports.
- agilob 4y agohttps://github.com/bigH/git-fuzzy https://github.com/bigH/git-fuzzy
- bilalq 4y agoI love how people share their fzf scripts whenever a new post comes along. I'll share some of my own. First, some env variables for setting defaults: export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git' export FZF_DEFAULT_OPTS='--layout=reverse --inline-info' export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" And some neat commands: 1. A command for fuzzy jumping between workspaces with tree previews (depends on `tree`): export WORKSPACE_ROOT="$HOME/whatever-your-root-is" ws() { cd "$WORKSPACE_ROOT/`ls -a $WORKSPACE_ROOT | fgrep -v .DS_Store | fzf --preview '(cd $WORKSPACE_ROOT/{1}; pwd; tree -C -L 1 -I node_modules -I .DS_Store)'`" } 2. A command to be able to fuzzy search files with previews and syntax highlighting. Depends on bat being installed. alias fzp="fzf --preview 'bat --style=numbers --color=always --line-range :500 {}' --border --height='80%'" 3. A command to fuzzily run npm scripts with previews and syntax highlighting. Depends on bat and gojq, but you can sub gojq with jq. It does have a bug where it doesn't handle ":" characters in script keys well, but I'll fix that at some point. npz() { local script script=$(cat package.json | gojq -r '.scripts | keys[] ' | fzf --preview 'cat package.json | gojq -r ".scripts | .$(echo {1})" | bat -l sh --color always --file-name "npm run $(echo {1})" | sed "s/File: /Command: /"') && npm run $(echo "$script") } 4. A command for rapidly selecting an AWS profile. As a user of AWS SSO with many accounts/roles, this is a life-saver. I combine this with having my prompt show the currently selected role for added value. alias aws-profile='export AWS_PROFILE=$(sed -n "s/\[profile \(.*\)\]/\1/gp" ~/.aws/config | fzf)' alias ap="aws-profile" 5. A command for fuzzily finding and tailing an AWS cloudwatch log group. I didn't come up with this one, and I can't remember where I read about it, or I'd attribute it properly. awslogs() { export AWS_PROFILE=$(cat ~/.aws/config | awk '/^\[profile /{print $2}' | tr -d ']' | fzf) local log_group=$(aws logs describe-log-groups | gojq -r '.logGroups[].logGroupName' | fzf) aws logs tail "$log_group" --since 3h --follow --format=short } I also have a few other commands related using fzf, but they're more bespoke and probably not useful to others.
- bloopernova 4y agoThat AWS logs one is fantastic.
- elAhmo 4y agojump (https://github.com/gsamokovarov/jump https://github.com/gsamokovarov/jump) is something I use as I didn’t know about Alt-C. Highly recommended
- rocketbop 4y agoI’m exactly in the same boat, after using both programs for years. Now I wonder if I can or should unlearn my j muscle memory.
- noloblo 4y agohow does it work, where do you use it does not do anything useful on my mac m1 j '' '' '' '' ''
- elAhmo 4y agoI just type in a fuzzy match for some of the directories I have visited. For example, if I know I frequently visit `/users/elahmo/developer/project`, if I type `j pro` I know it will jump there most of the time. If I type `j project`, it will jump 99% of the time. So it is quite good to cycle between things you often open, but of course you can reach things that are in the history it builds.
- noloblo 4y agoJump's database is empty. This could mean: 1. You are running jump for the first time. Have you integrated jump with your shell? Run the following command for help: $ jump shell If you have run the integration, enter a few directories in a new shell to populate the database. Are you coming from autojump or z? You can import their existing scoring databases into jump with: $ jump import Doesn't work afaik / Tried all doesn't work how do you set this up @elAhmo
- elAhmo 4y agoI didn't have to do any manual setup, I used it on ~three machines so far. Maybe something is odd with your shell? Which one do you use? I have seen other people suggesting https://github.com/wting/autojump https://github.com/wting/autojump too, so it might be worth giving that tool a look, it seems supported a bit better and more actively developed.
- spearman 4y agoThanks for this. I didn't know about the built-in-cd. For anyone on macOS trying to get Alt-C to work see https://github.com/junegunn/fzf/issues/164 https://github.com/junegunn/fzf/issues/164.
- baq 4y agoTL;DR - Esc+C works (yes you read that right, Esc+C)
- philbarr 4y agoI had to add the fzf plugin in my .zshrc to get this to work
- trufas 4y agoIf any other alacritty on macos users were looking for a workaround: https://github.com/alacritty/alacritty/issues/93#issuecomment-1364783147 https://github.com/alacritty/alacritty/issues/93#issuecommen... Apparently an option_as_alt option should also be introduced in the next release.
- e12e 4y agoIt's also possible to "fix" the keyboard via ukulele - especially international layouts come with a lot of cruft under option-key. Another possibility is to fix it via eg the terminal emulator - but that doesn't work for global hotkeys like window management with yabai via skhd. See my comment on lobsters: https://lobste.rs/s/nvoikx/helix_notes#c_m8guuh https://lobste.rs/s/nvoikx/helix_notes#c_m8guuh
- gregopet 4y agoWe have an IoT command server and connecting to one of the devices (for maintenance, logs or whatever) involved two manual lookups in the output of two commands and then finding your match in both. I was sick of this one day and with some grep, sed, awk and finally fzf, you could just sort of type the device's name and press "enter" to connect. People's reaction when I showed them was basically WHAT IS THIS MAGIC?!?
- jon-wood 4y agoThis is fantastic - I'm in a similar situation, and just threw together a quick FZF incantation to look up a device's ID for use in other commands.
- conradludgate 4y agoI 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 back that fzf-like experience [0]: https://github.com/ellie/atuin https://github.com/ellie/atuin [1]: https://github.com/lotabout/skim https://github.com/lotabout/skim
- nidnogg 4y agoThanks for the atuin reminder, I knew fzf reminded me of a crate I had on my backlog to try out but I completely forgot the name. I should probably just get to it now.
- noroot 4y agoI wanted to like atuin. The idea is great. But it just could not match the instant search that ctrl-r with fzf offers sadly. There is always a noticeable delay that annoyed me and made me revert back to fzf for search. For me another issue was that I needed to do more keystrokes for the same behaviour (search a previously ran command and execute it). Fuzzy shell history search is just one of those mind-blowing things. I love my history, it's such a trove and I can trust it to work as some kind of external memory (it's enough to vaguely know the kubectl command, or that I want to "du -h | sort" to see what is using disk space, etc).
- psYchotic 4y agoI also had a rather noticeable delay when launching atuin. As it turns out, this was because it checked for an update every time it launched! You can disable that update check: add a ` update_check = false` to your `~/.config/atuin/config.toml` [1]. That made the delay pretty much disappear for me. [1]: https://atuin.sh/docs/config/#update_check https://atuin.sh/docs/config/#update_check
- MayeulC 4y ago
- sva_ 4y agoIf anyone who uses i3 needs an fzf application launcher in their lives, adding the following two lines to your config will make $mod+d open it as a floating window in the middle (uses rxvt-unicode): bindsym $mod+d exec --no-startup-id urxvt -title "fzf-menu-random123" -e bash -c 'i3-dmenu-desktop --dmenu=fzf' for_window [title="fzf-menu-random123"] floating enable
- shmerl 4y agofzf lua is a cool plugin for neovim: https://github.com/ibhagwan/fzf-lua https://github.com/ibhagwan/fzf-lua So you don't need to do stuff like vi $(find . '/' | fzf) And instead can use fzf from inside the editor. It also supports integrating it with fdfind and ripgrep.
- aftbit 4y agoI use ctrlp.vim in vanilla vim with fzf. https://github.com/ctrlpvim/ctrlp.vim https://github.com/ctrlpvim/ctrlp.vim
- endorphine 4y agoAm I the only one that tried fzf as a replacement to the default Ctrl+R behavior, then switched back? I'm perfectly satisfied with the default Ctrl+R functionality, to the point that fzf seemed to add visual clutter without any value. I guess I was never let down by inverse search. Context: I'm using Linux and doing SWE and SRE work, and constantly live in the terminal.
- andelink 4y agoThe default ctrl+r behavior doesn't allow me to scroll up through my history of matches, which is always disappointing. Often it's some random incantation I'm trying to search for that shares a prefix with other more common commands and the default ctrl+r requires me to type out far enough to be unique, which defeats the purpose of history search. Maybe I'm missing some essential behavior that I'm not familiar with.
- babuskov 4y agoI don't know if the version I have is somewhat special, but I can simply keep pressing ctrl+r to search "up" for the next match. So, type: ctrl+r, prefix, and then keep pressing ctrl+r to find everything that matches the prefix.
- Izkata 4y ago> that shares a prefix ctrl+r matches any part of the line, not just the commands / start of the line. I'm often using it on a unique argument I remember last using the command with.
- jnsaff2 4y agoFor me (in a similar role to you) Ctrl+R is the main reason of having fzf. Quality of Life improvement is immense.
- bloopernova 4y agoImagine you have a bunch of different for loops and you want to get the one that ran a specific command. You can use something like "history | grep for | grep command" or you can use fzf. Ctrl-r, type "f o r <space>" then type "c o m m" and you'll quickly narrow down the search results. It's the fuzziness that really beats ordinary ctrl-r, being able to search on multiple fragments of text is just fantastic.
- spyremeown 4y agoAlright, you convinced me. Damn great article!
- _dain_ 4y agoFor me the killer feature is fuzzy tab completion. https://github.com/Aloxaf/fzf-tab https://github.com/Aloxaf/fzf-tab Install this, get an instant improvement to anything you do on the terminal. It works with any existing program with tab completion.
- VoodooJuJu 4y agoMost useful fzf thing for me is this: history | fzf
- campground 4y agoHere's a little function that I use pretty often when I want to install a package but I'm not sure what the exact package name is. Give it a keyword and it searches apt-cache and dumps the results into fzf. function finstall { PACKAGE_NAME=$(apt-cache search $1 | fzf | cut --delimiter=" " --fields=1) if [ "$PACKAGE_NAME" ]; then echo "Installing $PACKAGE_NAME" sudo apt install $PACKAGE_NAME fi }
- d12bb 4y agoI have a similar one for Homebrew, with the ability to preview package info and install multiple targets: # ~/.config/fish/functions/fbi.fish function fbi -a query -d 'Install Brew package via FZF' set -f PREVIEW 'HOMEBREW_COLOR=1 brew info {}' set -f PKGS (brew formulae) (brew casks |sed 's|^|homebrew/cask/|') set -f INSTALL_PKGS (echo $PKGS \ |sed 's/ /\n/g' \ |fzf --multi --preview=$PREVIEW --query=$query --nth=-1 --with-nth=-2.. --delimiter=/) if test ! -z "$INSTALL_PKGS" brew install $INSTALL_PKGS else echo "Nothing to install…" end end
- bloopernova 4y agoI have ctrl-r and alt-c assigned to macro keys on my keyboard, they're so danged useful. Something else you can try in your `~/.gitconfig` [alias] fza = "!git ls-files -m -o --exclude-standard | fzf -m --print0 | xargs -0 git add" git fza will quickly let you add files if you've changed a lot. I alias `git fza` to `ga` and it gets used a lot Oh, and another useful shortcut is this: export FZF_CTRL_T_COMMAND="mdfind -onlyin . -name ." Obviously only useful for MacOS, but fzf plus spotlight is pretty useful. You can use it to find that lost file that you only remember part of the name!
- andelink 4y agoI'm not super familiar with spotlight/mdfind. What are the benefits it offers over using the default `find` command with fzf?
- waynesonfire 4y agohave no need for this, plenty fast without it. these two have been sufficient for all my needs: ctrl + r for most things history | grep for searching when i forget the exact command or want to see related commands. I don't want pull downs, pull ups, drop downs, expanded hamburger menu, hot dogs, another set of key strokes to remember how i started some service last month.
- csdvrx 4y ago> I don't want pull downs, pull ups, drop downs, expanded hamburger menu, hot dogs, another set of key strokes to remember how i started some service last month You seem to be stuck in your ways, so that even when new better alternatives are created, you dismiss them unceremoniously, possibly without having taken the time to evaluate them. It's something I've noticed with quite a few linux users, and I find that super interesting! May I ask what's your age range? (just curious) Do you think the time spend in an exploratory phase for new tools (ex: getting familiar with fzy) would not be recovered by time gains in the exploitation phase? Or is it because of a fear of the unknown, or a belief that old habits may be hard to change? It's a very serious question BTW, I hope it's not too personal
- deleted 4y ago[deleted]
- jhatemyjob 4y agoThis example is hilarious to me: vi $(fzf) He claims to save a bunch of keystrokes by using it this way. But the string literal `vi $(fzf)` is saved in ~/.bash_history, not the actual filename. So you have to memorize the filename, AND deal with all those hamburgers and hot dogs, if you ever wanna re-edit that file after closing it.
- ursuscamp 4y agoI've been using fzf for a long time, but I didn't even know about Ctrl-R. Since I use fish, I've been used to just typing some random part of an old command, then hitting the Up key to cycle through old commands with that snippet. I'm going to have to give this a real shot.
- lumb63 4y agoI’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 that they need to search entire directory trees to find what they’re looking for? I’m confused.
- dharmab 4y agoI use Ctrl+R instead of hitting my up arrow key until I find a command I want to reuse.
- wahnfrieden 4y agoit's simple: search can be a better interface than manual tagging and organizing
- Timpy 4y ago> For Alt+C, are peoples’ file and directory layouts such a mess that they need to search entire directory trees to find what they’re looking for? Have you ever joined a new project? Usually they're both messy and you don't know where anything is. Besides, even now with plenty of familiarity in my current legacy code base I can use fzf to type filenames or directories without typing the full path. Ctrl+R is great for those repeat commands in your shell history that you want to use right now but don't want to add to your .bashrc, like repeatedly running a script with some arguments. I think the value of searching your history is self evident.
- mrguyorama 4y ago>Have you ever joined a new project? Shouldn't your new team members work to help onboard you instead? Shouldn't you get ample training in your job?
- csdvrx 4y ago
- deleted 4y ago[deleted]
- sigmonsays 4y agoI havn't seen it mentioned yet, you can also do fuzzy completion like cd * <tab> After pressing <tab> you get sent into fzf to make the decision This works for ssh too
- Grimm665 4y agoDid not know that worked for ssh, nice!
- hiAndrewQuinn 4y agoCrap, I forgot to include the whole *<TAB> thing! Man, good catch.
- effnorwood 4y ago[dead]
- jonfw 4y agoFZF is a great ad-hoc UI. Let’s say I want to run an operation against a cluster- it’s way better to use fzf to select clusters from a list than it is to have to copy/paste a particular cluster name
- leo-mednet 4y agoIf you are like me and cannot get any of these goodies working in zsh on Mac OS, do this: $(brew --prefix)/opt/fzf/install assuming you've installed fzf with brew.
- jrm4 4y agoI 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 type what you want. For me, it renders, e.g. "select in" and "case" functions in Bash completely obsolete. At any time, if I want quick selection of anything that can be a list, my first thought is, can I do this with fzf?
- rakoo 4y agoI have ~200 lines of scripts that use fzf and mblaze (https://github.com/leahneukirchen/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
- rustyminnow 4y agoYes 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.
- grimgrin 4y agoagreed. 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://github.com/junegunn/fzf/discussions/3211 https://asciinema.org/a/grALSk2M1tkVPiiyrAGCbdX5J https://asciinema.org/a/grALSk2M1tkVPiiyrAGCbdX5J (without width adjustment iirc)
- BeetleB 4y agoOther uses for fzf: - Combine it with autojump[1] and quickly navigate to any directory you've navigated to before (sorted by frequency). This is crazy helpful. - Use it for git branch names - Use it for ssh locations [1] https://github.com/wting/autojump https://github.com/wting/autojump
- wetpaws 4y agohow do I use it with autojump?
- BeetleB 4y agoautojump -s gets you the entries in the database. You have to parse it to extract the directories without all the metadata it spits out. Then you probably need to write a shell function in your preferred shell to tie the pieces together, as well as assign it to a keybinding. It's not too hard. I use xonsh for my shell, so my config probably won't help. And doing it in xonsh is probably a lot messier than doing it in Bash.
- dw_arthur 4y agoHere is the autojump function for fzf/bash https://github.com/junegunn/fzf/wiki/examples#autojump https://github.com/junegunn/fzf/wiki/examples#autojump You'll have to comment out the j() function in /usr/share/autojump/autojump.sh
- synergy20 4y agowith rg I rarely need fzf in practice, I would say for every 10,000 rg usage I need fzf once
- kbd 4y agoTo show off the power of fzf, I should share my fzr ("fzf repl") script: https://github.com/kbd/setup/blob/master/HOME/bin/fzr https://github.com/kbd/setup/blob/master/HOME/bin/fzr Basically, prefix any jq command (or rg, or anything you can think of) with fzr and it'll give you an interactive interpreter for your query. People have written a number of dedicated jq interactive repls, but not much is needed beyond fzf.
- E39M5S62 4y agofzf is fantastic. We use it to generate the entire interface of ZFSBootMenu - https://docs.zfsbootmenu.org/en/latest/_images/v2.1.0-multi-be.png https://docs.zfsbootmenu.org/en/latest/_images/v2.1.0-multi-... . It's leagues ahead of any other fuzzy finder in terms of scripting and layout capabilities.
- MayeulC 4y agoInteresting, 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 shell (doesn't complain about these permissions issues, and `fd abc` is equivalent to `find. -iname 'abc'`. A few comments here mention it already, but I wanted to recommend it.
- vonseel 4y agoI loveeee fd! About the only time I reach for find is if I need to do something with printf. I’ve noticed a bunch of CLI tools recently released written in rust that are along this same line of being snappy and well-written. Fclones, ripgrep, paru, fd, exa, to name a few. This probably has more to do with the type of developers the rust platform attracts, rather than the language itself (many awesome tools have been written in go recently as well). But yea, devs who have an interest in Linux and command line tools tend to be great IMO :)
- deleted 4y ago[deleted]
- abledon 4y agoif 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 https://youtu.be/qgG5Jhi_Els?t=400
- MayeulC 4y agoJust to explain a bit more... fzf is able to fuzzy-search a list for the input string. When it shows a list of directories, it relies on `find` to do so. fzf is also more suited to interactive search, while fd is more of a "give me a list" thing.
- asicsp 4y ago
- gajus 4y agoHow is fzf different from hstr?
- Orangeair 4y agoIs there a preceding blog post I could read here? Something like, "So you've just heard of fzf for the first time, what even is it?" I was kind of surprised that the author doesn't even make a passing attempt to define or explain it.
- petepete 4y agoThere isn't, but this one provides a good overview. https://www.redhat.com/sysadmin/fzf-linux-fuzzy-finder https://www.redhat.com/sysadmin/fzf-linux-fuzzy-finder The tl;dr is that it provides terminal fuzzy finding that can be plugged into just about any task that involves finding things. I use it many times an hour, it's the main way I navigate files and buffers in nvim, it's how I find files in my projects, it's how I select sessions in tmux. I'd be lost without it.
- Orangeair 4y agoThanks for the link!
- mickeyp 4y agoIf you're an Emacs user, then why not use Emacs as your fuzzy finder on the command line. I wrote about this a while back: https://www.masteringemacs.org/article/fuzzy-finding-emacs-instead-of-fzf https://www.masteringemacs.org/article/fuzzy-finding-emacs-i...
- dandanua 4y agoI've made a simple tagging solution based on fzf and don't know how to live without it anymore. You just name your folders and subfolders by tags. And then search it via fzf (I prefer the exact search) launched by a hotkey. To exclude a subfolder from the global search I use a trick. You add the stop symbol " #" at the end of the subfolder name. A custom fzf configuration (see below) then excludes what's the inside. Though, you still can cd into the excluded folder and make fzf search in it. So, in fact it gives you an hierarchy of tagged folders with stop symbols. This helps to avoid search pollution and unnecessary disk reads: export FZF_DEFAULT_COMMAND="fd -E=**/*#/**" I also use hotkeys to open items in default programs and to preview files in fzf UI: export FZF_DEFAULT_OPTS="--exact \ --bind 'ctrl-/:execute-silent(xdg-open {} &)' \ --bind 'ctrl-p:toggle-preview'" Of course, it still requires a strong discipline to tag everything appropriately. But the profit is immense - you can find everything you remember and open it in the default program in a matter of seconds.
- jpe90 4y agoif anyone is interested, here's a blog post about using fzf's file preview feature to preview grep results: https://jeskin.net/blog/grep-fzf-clp/ https://jeskin.net/blog/grep-fzf-clp/
- ryanbigg 4y agoI also like a Ctrl+T for finding a file in the current directory. For example: bundle exec rspec <Ctrl+T>
- grimgrin 4y agoi use it a lot but want an accompanying binding just for directories edit: okay done http://i.imgur.com/n12DYUu.png http://i.imgur.com/n12DYUu.png Two examples in case you have a preference w/ or w/o the preview: fzf_insert_directory_preview() { local dir dir=$(find . -type d -not -path '*/\.*' | fzf --height 40% --reverse --preview 'tree -C {} | head -200') if [[ -n $dir ]]; then READLINE_LINE="${READLINE_LINE}${dir}" READLINE_POINT=$((${#READLINE_LINE})) fi } fzf_insert_directory() { local dir dir=$(find . -type d -not -path '*/\.*' | fzf --height 40% --reverse) if [[ -n $dir ]]; then READLINE_LINE="${READLINE_LINE}${dir}" READLINE_POINT=$((${#READLINE_LINE})) fi } bind -x '"\ey": fzf_insert_directory_preview' # alt-y bind -x '"\et": fzf_insert_directory' # alt-t http://ix.io/4rtn/sh http://ix.io/4rtn/sh Sent from a LLM
- EamonnMR 4y agoI use fzf for all of my searching needs, especially on Mac where the default search is hot garbage.
- tetha 4y agoI recently setup something simple, but I've been falling in love with it - `goto`. Not as in the funny programming thing, with the even funnier `comefrom` variant in intercal, but as a simple shell script. My issue is that at work, I tend to work with a lot of projects and repos, and I work a whole lot in a couple repos. And honestly, even if its short, typing `cd ~/Pro<tab>/an<tab>/main_<tab>` becomes old after 2000 times or more. And then there are ~80 - 90 repos in ~/Projects/terraform, and a couple dozen legacy repos in ~/Projects/chef, a dozen different config repos in ~/Projects/config, an automatically rotating scratchpad in ~/Stuff, ... I don't know if it's a messy workstation, or I'm just dealing with a boatload of stuff. That's why I wrote goto. goto works in 2ish phases. The first phase just uses fzf -1 to give me a selection of the broad strokes I tend to navigate to. In case there is a prettier way to make fzf give me a static list of choices, let me know. It's basically: DESTINATION=$( echo "ansible\nterraform\nchef\nconfigs\n..." | fzf -1 "$1" ) This way I can either launch goto to get a list of 6-7 things I can select with arrows, by typing, or I can just be like `goto tf` and it directly selects `terraform`. After that, it's a big switch-case selecting where to `cd` to, as well as possibly doing some normal init things. `ansible` as a destination for example just CDs and that's it. `terraform` on the other hand does a bit more: case terraform) DESTINATION2=$( ls ~/Projects/terraform | fzf -1 "$2" ) cd "$DESTINATION2" git pull --rebase # more stuff ;; This way I can either say `goto`, select `terraform`, select a project and get moved there. Or I go `goto terraform` and type `prj2 foo` and usually fzf gives me the right thing, or I can be like `goto tf 'p2 fo'` and it drops me into the right place. Or something like `goto config infra-logaggregation` (or rather, `goto c ilg`). Or `goto stuff ticket-id` to get into some older scratchpad. I'll just have to consider if I want to stick with ohmyzshs alias of g == git, which I don't really use much. Then I could achieve the entirely readable `g c ilg` to go where I need to, hah. All of this is then wrapped into an alias, which basically aliases `goto` to be `source ~/goto`. IDK, thanks for listening to my TED-talk on how to use fzf to juggle way too many hats at once. It's just saved me a lot of keystrokes getting around and mashing incomprehensible spells into the shell so coworkers are confused is always fun.
- joemi 4y agoMaybe 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.
- grimgrin 4y agookay ignore everything you saw and just conceptualize: 1) list of text 2) input to filter the list down. see: list gets tinier
- TacticalCoder 4y ago> 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.
- ornornor 4y agoI wish asciinema was used for these instead of the gifs in article, GitHub, etc.
- chillpenguin 4y agoI agree, those animations were way too fast. I'm only 30 so it's probably not an age thing!
- berkes 4y agoMaybe "speed" is something they want to convey? An animation that shows a very slow pace might communicate that the tool is slow too.
- joemi 4y ago
- guestbest 4y agoI wish we still had Perl one liners since it is installed everywhere vi and gawk is installed. I’ve never seen fzf in the wild.
- roomey 4y agoI know, I am so used to ending up on different servers, I am worried about installing this on my own workstation, and getting used to it! I find myself getting tripped up even with zsh missing.
- pdntspa 4y ago> 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
- hiAndrewQuinn 4y agoNotice 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.
- pdntspa 4y agoIs tab-typing vi /etc/nginx/nginx.conf by hand really that much extra effort? Or, for this specific example, remember standard config file convention?
- wetpaws 4y agoJust spend entire morning setting fzf and this is lifechanging.
- wanderingmind 4y agoThe article talks about rg (ripgrep) but not rga (ripgrepall)[1] which extends rg to other file types like pdf, tar, zip. The rga website provides a function on integrating it with fzf[2] to interactively search documents from terminal. [1] https://github.com/phiresky/ripgrep-all https://github.com/phiresky/ripgrep-all [2] https://github.com/phiresky/ripgrep-all/blob/master/doc/rga-fzf.gif https://github.com/phiresky/ripgrep-all/blob/master/doc/rga-...
- mrzool 4y agoI loved this article since I was one of those who installed fzf, didn't get it, and walked away (at least twice).
- deleted 4y ago[deleted]
- phforms 4y agoI really like the suggested command `<my editor> $(fzf)` to quickly open files in <my editor> relative to the directory I am in. However, when I abort the fuzzy find with esc, it still opens <my editor> 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 }
- hiAndrewQuinn 4y agoI 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.
- phforms 4y agoI am very new to shell scripting and as I wrote the script, I actually just realized that I can plug anything into fzf that is split into lines of text and that I can use the selected output for further processing, since it’s just text. I just love how simple it is to stick anything together via the universal plain text interface in the shell and even pipe this text/dataflow through interactive tools like fzf, as you just mentioned.
- addingnumbers 4y agoIt returns non-zero exit codes when there are no matches or no selections made, so you can shorten that: fuzz() { file=$(fzf) && nvim "$file"; }
- kevinastock 4y agoI like `<editor> <ctrl-t>`; 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 `<editor> `.
- ornornor 4y agoYou could also map <ctrl-t> to fzf and then do `$EDITOR <ctrl-t>`. This works as you’d expect and with any command. I believe the instructions to set it up are in the fzf readme.
- kelnos 4y agoI'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 https://github.com/rupa/z
- brunoqc 4y agohttps://xkcd.com/1053/ https://xkcd.com/1053/
- dtgriscom 4y agoAmen!
- Nezteb 4y agoYou might like: https://github.com/ajeetdsouza/zoxide https://github.com/ajeetdsouza/zoxide Also all of the tools discussed in this thread (and more) are listed here: https://github.com/ibraheemdev/modern-unix https://github.com/ibraheemdev/modern-unix
- ilyagr 4y agohttps://github.com/skywind3000/z.lua https://github.com/skywind3000/z.lua is similar to `z` but has extra features, including a useful integration with `fzf`. It does require installing some version of command-line lua.
- strangelove026 4y agoI'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"
- vcdimension 4y agoI wrote a couple of shell tools based on fzf: https://github.com/vapniks/fzfrepl https://github.com/vapniks/fzfrepl: Edit commands/pipelines with fzf, and view live output while editing. There's a cool example using ffmpeg, graph2dot & graph-easy for displaying ffmpeg filter graphs. https://github.com/vapniks/fzf-tool-launcher https://github.com/vapniks/fzf-tool-launcher: Browse & preview contents of files, and launch tools/pipelines to process selected files. You can use fzfrepl in sequence to process each part of a dataprocessing pipeline with different tools.
- spapas82 4y ago> 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) https://en.m.wikipedia.org/wiki/Locate_(Unix) Using locate maybe piped to grep is good enough for all my finding needs
- willdr 4y agoDon't you need admin to run `updatedb`? On a work machine, this is my main barrier to using plocate.
- zamubafoo 4y agoCron/systemd timer to run updatedb every N hours.
- opan 4y ago`locate` doesn't seem to be on everything, unlike `find`. Same with `adduser` vs `useradd`. Both were a rude awakening to me later on as I hadn't learned the hard/common versions.
- berkes 4y agoLocate isn't always installed by default. 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.
- enriquto 4y agoThe 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.
- addingnumbers 4y agoAdd 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.)
- firecall 4y agoIs it me, or is that article unreadable due to the constantly looping gifs of terminals?
- talesvin 4y agoJust by knowing about alt+C blows my mind, i've been using fzf for a long time now and i basically just use ctrl+T with it, i don't know why i never looked into more shortcuts with it.
- collinvandyck76 4y agoI've incorporated fzf into so many shell scripts it feels like second nature now. Life without it would be bleak indeed :)
- mattweinberg 4y agoI'm a constant user of `fzf` and autojump (`j`) so combined them into this shell alias I use regularly: alias jf="cd \$(sort -nr ~/Library/autojump/autojump.txt | awk 'BEGIN {FS = \"\\t\"} {print \$2}' | fzf)" or without the escaping: cd $(sort -nr ~/Library/autojump/autojump.txt | awk 'BEGIN {FS = "\t"} {print $2}' | fzf) It gets my autojump history, sorts it by most used on top, extracts just the directory names, pipes the list to `fzf` and `cd`s into the selection. It's great because my most-used directories will be right on top of the `fzf` list.
- yesenadam 4y agoOn mac 12.5 + bash + macports, having trouble getting anything to work, like Ctrl-R, Esc-C etc, **TAB complete, even after trying to follow the suggestions linked here. The basic problem, however, is that whatever I type into the fuzzy search, it finds many thousands of hits. It seems it's picking up a lot of aliased Downloads folders in ~/Library/Containers. Anyone else have that problem? Not sure how to turn that off. I just typed "abcdefghijklmno" trying to narrow it down, and still had 10 hits. Typing a further "p" reduced that to 2, but I could see most of those eliminated 8 had a "p" in the filename. Confusing! edit: I got Ctrl-R, Esc-C and **TAB complete working by adding this to .bash_profile, not .bashrc as it said to when installing: source /opt/local/share/fzf/shell/key-bindings.bash source /opt/local/share/fzf/shell/completion.bash But I still have many thousands of options for Esc-C cding, for example, whatever I type—mostly from ~/Library/Containers. I don't remember having that problem when I tried fzf a few years ago, on macos 10.13 I think.
- erichlee 4y agoDropping to say I miss your Twitter account man, I remember doing how-to-host-one-html.page years ago. Keep posting bangers king.
- hiAndrewQuinn 4y agoblush
- aftbit 4y agoThe meaning of find . '/' Was not immediately apparent to me. It will first search the current directory, then search from the root directory of the filesystem. This is useful (beyond just `find` which is implicitly `find .`) because it will turn up local results quickly and global results eventually.
- hiAndrewQuinn 4y agoI actually did not catch myself that it has that two-tiered behavior. That's fascinating! Maybe I would have found nginx faster if I had reflexively hopped to /etc first.
- julienpalard 4y agoSame as: find . / Don't get why there's quoting here.
- greggyb 4y agoThe article is a pretty helpful collection of examples, and I appreciate it. The intro irks me, though: > Software engineers are, if not unique, then darn near unique in the ease with which we can create tools to improve our own professional lives; this however can come at a steep cost over time for people who constantly flit back and forth between different tools without investing the time to learn their own kit in depth. As someone with a healthy respect for the tacit knowledge of people better than me, I think a great 80/20 heuristic is “Learn the oldies first”: venerable Unix tools like cat, ls, cd, grep, and cut. (sed and awk, too, if you have the good fortune of landing yourself in an actual modern sysadmin role.) This seems to be either naive or hubristic in light of the thousands of years of history of craftspeople building their own workspaces. Even a hobbyist woodworker will build plenty of jigs and fixtures for their work. Machinists as well. Anyone whose work comprises building things is readily capable of applying those skills to make their work easier
- wsintra 4y agounique in the ease with which we can create tools to improve our own professional lives I think the key line is the ease in which we can create tools. A software engineer has free access to the lumber yard. Builders of old had to work hard to create tools to create tools.
- wnolens 4y agoNo capital costs, and seldom held back by constraints of the existing tools were using to build the next tool.
- greggyb 4y agoCost and ease are different concerns. On ease, much of what a woodworker needs can be built from wood and with basic hand tools, so the woodworker, by definition can build many of their own tools. This is similar to programming, where much of what a programmer needs can be written in code. On cost, simple observation of woodshops—including many in person and among acquaintances that are not professionals—has shown me that the cost is not prohibitive. Every shop I have seen includes a significant amount of self-built tools and fixtures. Cost also explains the difference in programming environments I have seen. I have met a great many professional programmers, some of whom have no scripts directory or self-written tools, whose only programming output is their direct work product. This reflects the fact that professional-grade tools are available for free to programmers. As individuals, my observations lead me to understand woodworkers as much more likely to use their skills to build tools for themselves. The same holds true of other craftspeople I have had the opportunity to observe; even in small, one-off projects, it is common to use elements of the craft to build a tool or otherwise aid the endeavor in a way that is not directly producing the work product. As a collection, I would agree that programmers build tools that allow us to do our work better. The open source community is incredible. Because of the collective action and the cost to individuals, it is much less common for those individual programmers to have to write tools for themselves. I would argue that it is similarly easy, but circumstances lead to these disparate outcomes.
- dracodoc 4y agoFor windows, I like everything search https://www.voidtools.com/ https://www.voidtools.com/ It let you search all your files and folders instantly as long as they are ntfs partions, and there is no heavy background indexing needed(it still need to do index but it's very light since it use ntfs file journal to build it) . I also customize it so I can click the folder in the UI and open it in total commander.
- no_carrier 4y agoThis article makes things more complicated than they need to be: > vi $(find . '/' | fzf): For finding random config files Instead you can just use: > vi **<tab> ** is the real gamechanger here. You can use it with ssh, too. I managed about 500 SSH hosts. ssh **<tab> will find hosts via /etc/hosts and .sshconfig
- ar9av 4y agoSurprised Ctrl+T didn't get a mention. Maybe that's a zsh-only thing, but it's basically the same as his vim $(fzf) example, except I only have to type vim and then Ctrl+T. I use this all the time when I'm running unit tests from the command line for instance. Helps me quickly get the path to the file I want without needing to remember the details of the folder structure. Just Ctrl+T -> tests/GLPage will yield me tests/long_path/GoddamnLoginPageTests.foo
- ornornor 4y agoThere is also `**<ctrl-t>` for thing like ssh auto completion and others.
- _h9mb 4y agoShameless plug: https://github.com/danisztls/fzfx https://github.com/danisztls/fzfx It tries to solve the "now what" part.
- zedadex 4y ago> You get only one preview, so if you miss that exact match by even one character, you’re on a wild goose chase Which has done wonders for my memory :D (You _can_ cycle through past entries, but will check this out as list does sound way better + the menus people are describing here sound interesting)
- parentheses 4y agoShameless plug for my fzf-integrated git tooling: https://github.com/bigH/git-fuzzy https://github.com/bigH/git-fuzzy
- solatic 4y agoI 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.
- hiAndrewQuinn 4y agoxargs is an absolute game changer in this regard, once I realized what it actually did I started seeing fzf >>= xargs flows everywhere!
- seruman 4y agoMy alternative to `prv` with preview; 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 {}"
- hiAndrewQuinn 4y agoOP here, thank you all for your kind and insightful comments. There are a lot of very talented fzf users here! I wrote this post following diataxis.fr's advice on writing tutorials: >A tutorial must help a beginner achieve basic competence with a product, so that they can go on to use the product for their own purposes. >A tutorial also needs to show the learner that they can be successful with the product - by having them do something both meaningful and attainable. I think I have succeeded on that front judging by the reaction. :) https://diataxis.fr/tutorials/ https://diataxis.fr/tutorials/
- mariusmg 4y agoPersonally i never like the "interactive" part of fzf, ideally i should be able to do micro | fzf "myfile" and have it opened in the editor (fzf matching the first result for the file name) Instead it's : micro $(fzf) , then type the filename , select it and presee enter to get it opened in the editor.
- 098799 4y agoIs it just me or is it mildly annoying that I need to press enter twice if I Ctrl-R with fzf, as opposed to once with the regular search?
- elAhmo 4y agoI just checked this, I thought you got it wrong, but you are indeed right :D I was never annoyed by this, I see the first enter as to confirm the "search results", and then another to to actually execute the command.
- sfc32 4y agoGreat blog post, strange choice of image (comment by Ciara).
- sfc32 4y agoA little typo: For when you neither rememeber exactly
- mrinterweb 4y agoOne way I use the trigger character(s) so I can use fzf anywhere in my prompt. For example setting: export FZF_COMPLETION_TRIGGER='~~' Will allow fzf completion for a commands. Just need to hit the <TAB> key after ~~ and fzf will pop up: git diff main..HEAD -- ~~ ls -lh ~~
- singiamtel 4y agoDid the web server go down?
- hiAndrewQuinn 4y agoYeah, sorry! Hug of death, redeploying w/ a big boy hosting provider now
- SuperSandro2000 4y agoOnly a 404, but still living fzf since forever.
- hiAndrewQuinn 4y agoSwitching hosting providers, stay tuned~
- hiAndrewQuinn 4y agohttps://www.andrew-quinn.me/fzf/ https://www.andrew-quinn.me/fzf/ OP here! Apex domains are hard! Sorry, this one works fine now.