Published on

File system navigation made fuzzier using fzf-cd command

301 words2 min read
Authors

File system navigation made fuzzier using fzf-cd command

Introduction

One of the things that I found really hintering my productivity is the time I spend navigating through the file system. I have been using the cd command for a long time and I have been using the fzf for a while, in my neovim setup(which is pretty neat by the way). But in my day to day work, I have to navigate through the file system a lot. So I thought why not combine the two and make my life easier. So I did and I am going to share it with you. This will be a quick guide on how to setup the fzf-cd command.

Prerequisites

  • fzf installed

If you don't have fzf installed, you can follow the official guide to install it.

Setup

Go to your ~/.bashrc or ~/.zshrc file and add the following lines at the end of the file.

# fzf-cd
fcd() {
  local directory
  directory=$(find * -type d 2>/dev/null | fzf +m) && cd "$directory"
}

Now, you can either restart your terminal or run source ~/.bashrc or source ~/.zshrc to load the changes.

That's it. Now you can use the fcd command to navigate through the file system. You can also use the fcd command with the zsh plugin zsh-autosuggestions to make it even more easier.

fcd-gif

Conclusion

I hope you found this guide useful. If you have any questions or suggestions, feel free to reach out to me on twitter.