Post

Modern CLI Tools

Modern CLI Tools

I’ve been trying and learning more modern CLI tools with faster, more ergonomic alternatives. I am documenting a few of my favorites.

zoxide: Modern cd

zoxide learns your directory usage and lets you jump to frequently visited paths with partial matches.

1
brew install zoxide

After installing, add this to your .zshrc:

1
eval "$(zoxide init zsh)"

Now instead of typing full paths:

1
2
3
4
5
# Before
cd ~/dev/projects/company/frontend/src

# After - just type a partial match
z frontend

zoxide ranks directories by frequency and recency. The more you visit a path, the higher it ranks.

ripgrep: Fast Recursive Search - Modern grep

ripgrep (rg) is a grep replacement that’s faster and respects .gitignore by default.

  • note: respecting .gitignore is a bug for some people, so be aware of that. To override, use --no-ignore.
1
brew install ripgrep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Search for "useState" in all files
rg useState

# Case insensitive
rg -i usestate

# Only in TypeScript files
rg useState -t ts

# Show context around matches
rg useState -C 3


# Don't respect .gitignore
rg useState --no-ignore

The speed difference is noticeable!

fd: Better File Finding

fd modern alternative to find.

1
brew install fd
1
2
3
4
5
6
7
8
# Find all TypeScript files
fd -e ts

# Find files matching a pattern
fd "test.*\.ts$"

# Find and delete node_modules directories
fd -t d node_modules -x rm -rf {}

I like the syntax more than find, and it ignores .gitignore patterns by default.

  • note: opposite of rg, by default it ignores .gitignore which be a bug for some people. 😀 Use --no-ignore to override.

fzf: Fuzzy Finder for Everything

fzf is a general-purpose fuzzy finder that integrates with your shell.

1
brew install fzf

After installing, run the install script to set up shell integration:

1
$(brew --prefix)/opt/fzf/install

This gives you:

  • Ctrl+R - Fuzzy search command history this is what I use most!
  • Ctrl+T - Fuzzy find files in current directory
  • Alt+C - Fuzzy cd into subdirectories

You can also pipe anything into it:

1
2
3
4
5
# Select a branch to checkout
git branch | fzf | xargs git checkout

# Select a process to kill
ps aux | fzf | awk '{print $2}' | xargs kill

Installation Summary

1
brew install zoxide ripgrep fd fzf

These tools work well together. You can combine fd with fzf for interactive file selection, and rg with fzf for searching and jumping to results.

This post is licensed under CC BY 4.0 by the author.