fzf चीटशीट

0.57

सब कुछ fuzzy find करें — files, history, processes, और बहुत कुछ

हिन्दी: 2026-03-29

fzf आपके terminal के लिए एक fuzzy finder है, और जब आप इसे इस्तेमाल करना शुरू करेंगे, तो सोचेंगे कि इसके बिना कैसे काम चलता था। कुछ भी इसमें pipe करें — file lists, git branches, process IDs, environment variables, शाब्दिक रूप से कोई भी line-based input — और fzf आपको एक instant, interactive, typo-माफ़ करने वाला search interface देता है। "400 lines के output में हर एक को घूर-घूरकर scroll करना" बदल जाता है "तीन characters type करो और पहुँच गए।"

fzf की खूबसूरती यह है कि यह एक Unix filter है। यह stdin से lines पढ़ता है, आपको एक (या कई) चुनने देता है, और आपकी selection stdout पर लिख देता है। बस इतना ही। यह सीधा contract मतलब है कि यह हर चीज़ में plug हो जाता है। इसे find, rg, git, ps, docker, या किसी भी text produce करने वाली चीज़ के साथ combine करें, और आपके पास free में एक interactive selector है। यह terminal workflows का duct tape है — बस यह वाकई में elegant है।

यह cheatsheet उन patterns पर focus करती है जो आप लगातार इस्तेमाल करेंगे: core commands, shell integrations जो आपके filesystem navigate करने का तरीका बदल देंगे, preview window जो selections को luxurious बना देता है, और real-world recipes जो fzf को "अच्छा toy" से "ज़रूरी infrastructure" में बदल देती हैं। अगर यहाँ सिर्फ तीन चीज़ें सीखनी हैं, तो वे हैं Ctrl-R, Ctrl-T, और --preview flag। बाकी सब bonus है।

बुनियादी उपयोग

fundamentals। ज़्यादातर लोग यहाँ से शुरू करते हैं और कभी realize नहीं करते कि rabbit hole कितना गहरा है।

बुनियादी उपयोग
fzf
वर्तमान directory से recursive file list के साथ fzf launch करें
<cmd> | fzf
किसी भी command output को interactive filtering के लिए fzf में pipe करें
fzf --query "str"
पहले से भरी हुई search query के साथ शुरू करें
fzf --filter "str"
Non-interactive mode — matches stdout पर print करके exit करें
fzf --select-1
अगर सिर्फ एक match हो तो auto-select करें
fzf --exit-0
कोई match नहीं होने पर तुरंत exit करें
fzf -m
Multi-select mode enable करें (Tab से selections toggle करें)
fzf --height 40%
fullscreen के बजाय fzf inline खोलें
fzf --reverse
list को bottom-up के बजाय top-down display करें
fzf --exact
Fuzzy matching disable करें — सिर्फ exact substring matches दिखाएँ

Search Syntax

fzf की search language छोटी है लेकिन surprisingly powerful। आप इन tokens को एक ही query में combine कर सकते हैं।

Search Syntax
sbtrkt
Fuzzy match — characters क्रम में होने चाहिए, लेकिन लगातार नहीं
'wild
Exact match (single quote prefix के साथ)
^music
Prefix exact match — "music" से शुरू होना चाहिए
.mp3$
Suffix exact match — ".mp3" पर खत्म होना चाहिए
!fire
Inverse exact match — "fire" वाली lines exclude करें
!'.mp3$
Inverse suffix match — ".mp3" पर खत्म होने वाली lines exclude करें
foo | bar
OR operator — "foo" या "bar" वाली lines match करें

fzf के अंदर Key Bindings

fzf खुलने के बाद, ये keys navigation और selection control करती हैं।

fzf के अंदर Key Bindings
Ctrl-j / Ctrl-n
Cursor नीचे ले जाएँ
Ctrl-k / Ctrl-p
Cursor ऊपर ले जाएँ
Enter
वर्तमान selection accept करें
Tab
Multi-select mode (-m) में selection toggle करें
Shift-Tab
Multi-select mode में deselect करें
Ctrl-a
सभी matches select करें (multi-select mode)
Ctrl-d
सभी deselect करें (multi-select mode)
Ctrl-/
Preview window visibility toggle करें
Ctrl-c / Esc
Cancel करें और fzf से बाहर निकलें
Ctrl-l
Search query clear करें

Shell Integrations

ये तीन bindings हैं जो fzf को superpower जैसा बनाती हैं। ये सीधे आपके shell में wire होती हैं और installation के बाद out of the box काम करती हैं।

Shell Integrations
Ctrl-R
Shell command history में search करें — fzf का सबसे बढ़िया feature
Ctrl-T
Files ढूंढें और selected path command line में paste करें
Alt-C
Fuzzy-find करके directory में तुरंत cd करें
**<Tab>
fzf completion trigger करें (जैसे vim **<Tab>, cd **<Tab>)
kill **<Tab>
Completion के ज़रिए kill करने के लिए process fuzzy-find करें
ssh **<Tab>
known_hosts / ssh config से host fuzzy-find करें

Preview Window

Preview window fzf को एक selector से full browser में बदल देता है। आप files, syntax-highlighted code, images, git diffs — कुछ भी preview कर सकते हैं जो किसी command से pipe हो सके।

Preview Window
--preview "cat {}"
Preview pane में file contents दिखाएँ
--preview "bat --color=always {}"
bat के साथ syntax-highlighted preview (gold standard)
--preview-window right:60%
Preview दाईं तरफ रखें, 60% width लेते हुए
--preview-window up:50%:wrap
Preview ऊपर रखें line wrapping के साथ
--preview-window hidden
Preview छुपा कर शुरू करें, Ctrl-/ से toggle करें
--bind "ctrl-u:preview-half-page-up"
Ctrl-u को preview में ऊपर scroll करने के लिए bind करें
--bind "ctrl-d:preview-half-page-down"
Ctrl-d को preview में नीचे scroll करने के लिए bind करें

सामान्य Patterns

ये copy-paste recipes हैं जो fzf को अनिवार्य बनाती हैं। हर एक एक real problem solve करती है जो शायद आपको इसी हफ्ते हुई हो।

Process Management
kill -9 $(ps aux | fzf | awk '{print $2}')
Fuzzy-find करके process kill करें
ps aux | fzf -m | awk '{print $2}' | xargs kill
एक साथ कई processes kill करें
Git Workflows
git branch | fzf | xargs git switch
Fuzzy-find करके git branch switch करें
git log --oneline | fzf --preview "git show {1}"
Diff preview के साथ commits browse करें
git diff --name-only | fzf --preview "git diff {}"
Inline diff के साथ changed files browse करें
git stash list | fzf | cut -d: -f1 | xargs git stash pop
Interactively stash चुनकर pop करें
Docker
docker ps | fzf | awk '{print $1}' | xargs docker stop
Fuzzy-find करके चल रहा container रोकें
docker images | fzf | awk '{print $3}' | xargs docker rmi
Fuzzy-find करके image हटाएँ
docker logs -f $(docker ps | fzf | awk '{print $1}')
चुने हुए container के logs tail करें
File और Directory Navigation
vim $(fzf)
Fuzzy-found file को अपने editor में खोलें
cd $(fd -t d | fzf)
Directory fuzzy-find करके उसमें cd करें
rg --files | fzf --preview "bat --color=always {}"
Syntax-highlighted preview के साथ project files browse करें
rg -l "pattern" | fzf --preview "rg --color=always pattern {}"
Pattern से matching files ढूंढें, context में matches preview करें

Tips

FZF_DEFAULT_COMMAND को default find के बजाय fd या rg इस्तेमाल करने के लिए set करें। ये तेज़ हैं, .gitignore respect करते हैं, और node_modules जैसे junk को automatically skip करते हैं। अपने shell profile में export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git' try करें।

Shell integrations को FZF_CTRL_T_COMMAND, FZF_CTRL_R_OPTS, और FZF_ALT_C_COMMAND से independently customize करें। उदाहरण के लिए, FZF_ALT_C_COMMAND='fd --type d' set करें ताकि Alt-C blazing-fast directory search के लिए fd इस्तेमाल करे और automatically .gitignore entries ignore करे।

अपने default fzf options FZF_DEFAULT_OPTS में रखें ताकि वे हर जगह apply हों। एक अच्छी शुरुआत: export FZF_DEFAULT_OPTS='--height 40% --reverse --border --preview-window right:50%:wrap'। यह आपको हर invocation पर preview pane के साथ एक compact, top-down layout देता है।

Custom actions जोड़ने के लिए --bind इस्तेमाल करें। उदाहरण के लिए, --bind 'ctrl-y:execute-silent(echo {} | pbcopy)' fzf छोड़े बिना current selection को clipboard पर copy करता है। आप किसी भी key को execute, reload, preview, या fzf के behavior को on the fly बदलने के लिए bind कर सकते हैं।

--preview command के पास placeholders हैं: {} पूरी line है, {1} पहला field है, {q} current query है, और {n} line number है। ये आपको wrapper script लिखे बिना surprisingly sophisticated previews बनाने देते हैं।

अपने custom scripts को user-friendly context देने के लिए fzf को --header के साथ chain करें। git branch | fzf --header "Switch to branch:" जैसा कुछ throwaway scripts को polished feel देता है। Search prompt text customize करने के लिए --prompt के साथ pair करें।

tmux में, fzf inline के बजाय popup में खुल सकता है। Centered floating popup window में fzf launch करने के लिए fzf-tmux -p 80%,60% इस्तेमाल करें। यह slick है, आपके main pane से बाहर रहता है, और काम होने पर गायब हो जाता है। एक बार try करने के बाद, inline fzf cramped लगेगा।

Related Tools