Productive Terminal
FZF has truly transformed the way I interact with the command line. Give it a try, and you'll wonder how you ever lived without it!
What is FZF?
FZF is a versatile command-line tool that allows you to search and filter through lists of items with lightning speed. Whether you're looking for files, browsing command history, or selecting from a list of options, FZF makes the process effortless and intuitive.Like any other tool, the first step is installation. You can find installation instructions based on your operating system and preferred method at FZF's GitHub page.
5 Useful FZF Recipes
1. Quick File Opening
Quickly search for and open files in Vim or VS Code
alias vf='vim $(fzf)' # For Vim users
alias cf='code $(fzf)' # For VS Code users
2. Interactive Directory Navigation
Easily navigate to any subdirectory within your current location
alias cdf='cd $(find . -type d | fzf)'
3. Git Branch Switching
Quickly switch between Git branches without typing long branch names
领英推荐
alias gbr='git checkout $(git branch | fzf)'
4. Process Killing
Interactively select and terminate processes
alias fkill='kill -9 $(ps aux | fzf | awk "{print $2}")'
5. Command History Search
Quickly find and re-run previous commands from your shell history. This is where I was introduced to FZF.
alias fh='eval $(history | fzf | cut -c 8-)'
To store these aliases permanently, add them to your shell configuration file (e.g., .bashrc, .zshrc, or .bash_profile) depending on your shell. This way, they'll be available every time you open a new terminal session.
https://vitormv.github.io/fzf-themes/ provides a way to easily customize the theme of the FZF interface.
My personal setting :
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border --color=bg+:#282a36,bg:#44475a,fg:#f8f8f2,prompt:#50fa7b,pointer:#ff79c6,marker:#ffb86c"
These commands might not look intuitive at first, but once you start working with FZF, you'll be amazed and wonder why you never knew about it! There is a ton of potential in this tool, and I have yet to explore anything beyond these basics.