brew install fzf | Install on macOS |
apt install fzf | Install on Ubuntu |
git clone https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install | Install from git |
fzf | Find files interactively |
find . | fzf | Pipe to fzf |
ls | fzf | Select from list |
cat file | fzf | Search in file content |
fzf --preview "cat {}" | With file preview |
Ctrl+J / Ctrl+N | Move down |
Ctrl+K / Ctrl+P | Move up |
Enter | Select item |
Tab | Mark item (multi-select) |
Shift+Tab | Unmark item |
Ctrl+A | Select all |
Ctrl+D | Deselect all |
Ctrl+T | Toggle item selection |
Esc / Ctrl+C | Cancel |
Ctrl+T | Paste file path |
Ctrl+R | Search command history |
Alt+C | cd into directory |
fzf --height 40% | Limit height |
fzf --reverse | Reverse list |
fzf --border | Show border |
fzf --border=rounded | Rounded border |
fzf --margin 1,5% | Set margins |
fzf --padding 1 | Set padding |
fzf --prompt "Select> " | Custom prompt |
fzf --pointer ">" | Custom pointer |
fzf --header "Pick a file" | Add header |
fzf -m | Multi-select mode |
fzf --no-multi | Single select |
fzf --select-1 | Auto-select if only one |
fzf --exit-0 | Exit if no match |
fzf -q "query" | Start with query |
fzf -1 | Select first match |
fzf -e | Exact match |
fzf -i | Case insensitive |
fzf +i | Case sensitive |
fzf --algo=v1 | Faster algorithm |
fzf -n 2 | Search only 2nd field |
fzf -n 2.. | Search 2nd field onwards |
fzf -d ":" -n 1 | Custom delimiter |
fzf --preview "cat {}" | Preview file content |
fzf --preview "head -100 {}" | Preview first 100 lines |
fzf --preview "bat --color=always {}" | Preview with bat |
fzf --preview-window right:50% | Preview on right |
fzf --preview-window down:40% | Preview below |
fzf --preview-window hidden --bind "?:toggle-preview" | Toggle preview with ? |
fzf --bind "ctrl-a:select-all" | Select all |
fzf --bind "ctrl-d:deselect-all" | Deselect all |
fzf --bind "ctrl-y:execute-silent(echo {} | pbcopy)" | Copy to clipboard |
fzf --bind "enter:execute(vim {})" | Open in vim |
fzf --bind "ctrl-o:execute-silent(open {})" | Open file |
fzf --bind "?:toggle-preview" | Toggle preview |
fzf --bind "ctrl-j:down,ctrl-k:up" | Vim-like navigation |
vim $(fzf)
# Or with preview
vim $(fzf --preview "bat --color=always {}") cd $(find . -type d | fzf)
# Alias
alias fcd='cd $(find . -type d | fzf)' kill $(ps aux | fzf | awk '{print $2}')
# Or interactive
kill -9 $(ps aux | fzf -m | awk '{print $2}') git checkout $(git branch | fzf)
# With remote branches
git checkout $(git branch -a | fzf | sed 's/remotes\/origin\///') git log --oneline | fzf --preview "git show {1}" docker exec -it $(docker ps | fzf | awk '{print $1}') bash # Search content and open file
fif() {
local file
file=$(rg --files-with-matches --no-messages "$1" | fzf --preview "rg --color=always -n '$1' {}")
if [ -n "$file" ]; then
vim "$file"
fi
} # Use fd instead of find
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude .git' # .bashrc or .zshrc
export FZF_DEFAULT_OPTS='
--height 40%
--reverse
--border
--preview-window right:50%
--bind ctrl-a:select-all
--bind ctrl-d:deselect-all
--bind ?:toggle-preview
' export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS'
--color=fg:#d0d0d0,bg:#121212,hl:#5f87af
--color=fg+:#d0d0d0,bg+:#262626,hl+:#5fd7ff
--color=info:#afaf87,prompt:#d7005f,pointer:#af5fff
--color=marker:#87ff00,spinner:#af5fff,header:#87afaf
'