The Dev Log › Tips & Cheat Codes
Terminal Productivity for Developers: zsh Aliases, fzf and ripgrep
By Jezer Niel Blanca, Full Stack Developer ·
·
6 min read
The zsh setup I recommend: built-in shortcuts, aliases and functions, better history, and modern tools like fzf, ripgrep, fd, bat and zoxide.
The terminal is where I run tests, deploy, search code, manage Git and poke at servers, so small improvements there pay off many times a day. You don't need a fancy setup or hours of configuration to get most of the benefit. A handful of aliases, a few modern command-line tools and some keyboard shortcuts will make you noticeably faster. Here's the zsh setup I recommend to developers, focused on the pieces that give the biggest return for the least effort.
Keyboard Shortcuts You Already Have
Before installing anything, learn the shortcuts built into zsh. They work in almost any terminal and save a lot of arrow-key tapping:
- Ctrl+A and Ctrl+E jump to the start and end of the line.
- Ctrl+W deletes the previous word, and Ctrl+U deletes everything before the cursor.
- Ctrl+R searches your command history backwards.
- Alt+. (or Esc then .) inserts the last argument of the previous command.
!! repeats the previous command, so sudo !! reruns it with sudo.
cd - jumps back to the previous directory.
That last-argument shortcut is one of my favourites. Run mkdir -p app/Services/Billing, then type cd and press Alt+. to fill in the path.
Aliases and Functions for Repeated Commands
Any command you type several times a day deserves an alias. Add these to your ~/.zshrc:
alias pa="php artisan"
alias pat="php artisan test --compact"
alias gs="git status -sb"
alias gl="git log --oneline --graph --decorate -20"
alias gco="git checkout"
alias ..="cd .."
alias ...="cd ../.."
Keep aliases short but memorable. If you forget an alias exists, it's not saving you anything.
Functions for Anything With Arguments
Aliases can't easily take arguments in the middle of a command. Shell functions can:
mkcd() {
mkdir -p "$1" && cd "$1"
}
port() {
lsof -nP -iTCP:"$1" -sTCP:LISTEN
}
gnew() {
git switch -c "$1" && git push -u origin "$1"
}
mkcd creates and enters a folder in one step, port 5173 shows what's listening on a port, and gnew feature/login creates a branch and pushes it upstream.
After editing ~/.zshrc, run source ~/.zshrc to load the changes into your current session.
Better History Settings
Your command history is a personal library of every command you've run. A few settings make it far more useful:
HISTFILE=~/.zsh_history
HISTSIZE=50000
SAVEHIST=50000
setopt SHARE_HISTORY
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_REDUCE_BLANKS
Here's what those options do:
SHARE_HISTORY shares history between open terminal tabs, so a command run in one is available in another.
HIST_IGNORE_ALL_DUPS removes older duplicates so searching isn't cluttered.
HIST_IGNORE_SPACE skips any command that starts with a space. That's handy when a command includes a token you don't want saved.
HIST_REDUCE_BLANKS tidies up extra spaces.
Modern Tools Worth Installing
A few modern command-line tools replace older ones with faster, friendlier versions. On macOS I install them with Homebrew, and most are available through Linux package managers too:
brew install fzf ripgrep fd bat zoxide jq
fzf: Fuzzy Find Everything
fzf is a fuzzy finder that turns any list into an interactive search. Enable its shell integration in ~/.zshrc:
source <(fzf --zsh)
That gives you three superpowers:
- Ctrl+R becomes a fuzzy search through your entire history. Type any fragment of a command you remember.
- Ctrl+T fuzzy-finds a file and inserts its path into the current command.
- Alt+C fuzzy-finds a directory and changes into it.
You can also pipe anything into fzf. This function lets you switch Git branches by typing part of the name:
gb() {
git branch --format='%(refname:short)' | fzf | xargs git switch
}
ripgrep: Search Code Fast
ripgrep, run with rg, searches file contents recursively, respects .gitignore and is very quick even in large projects:
rg "RateLimiter::for"
rg -t php "implements ShouldQueue"
rg -l "defineModel" resources/js
rg -i "todo" --glob "!vendor"
-t php limits the search to PHP files, -l lists only file names, -i makes it case-insensitive, and --glob includes or excludes paths.
fd, bat, zoxide and jq
- fd finds files by name with simple syntax:
fd Controller app/Http.
- bat is
cat with syntax highlighting and line numbers: bat routes/web.php.
- zoxide learns the folders you visit. After adding
eval "$(zoxide init zsh)" to your config, z nielblanca jumps to a project from anywhere.
- jq formats and queries JSON:
curl -s https://api.example.com/items | jq '.data[0]'.
The best terminal upgrade isn't a theme. It's fuzzy history search. Once Ctrl+R understands fragments, you'll stop retyping long commands forever.
Git in the Terminal, Faster
Git is where many developers spend most of their terminal time. Beyond aliases, a few Git settings help:
git config --global pull.rebase true
git config --global push.autoSetupRemote true
git config --global rerere.enabled true
git config --global alias.undo "reset --soft HEAD~1"
push.autoSetupRemote means the first git push on a new branch sets up tracking automatically. rerere remembers how you resolved a conflict and reuses that resolution if the same conflict appears again. And git undo reverses the last commit while keeping the changes staged.
Keep Your Prompt Informative but Quick
A prompt that shows the current branch and whether there are uncommitted changes prevents a lot of mistakes. Frameworks like Oh My Zsh or cross-shell prompts like Starship make this easy. Whatever you choose, keep it fast. A prompt that pauses before every command gets annoying quickly.
Keep Your Setup Portable
Once your config is useful, protect it. I keep my .zshrc and other dotfiles in a Git repository so I can set up a new machine in minutes and roll back a change that breaks something. Add comments to explain anything non-obvious, because you won't remember why you added that one alias in six months.
Wrapping up
A faster terminal comes from simple things: built-in shortcuts like Ctrl+R and Alt+., aliases and small functions for repeated commands, better history settings, and a few modern tools like fzf, ripgrep, fd, bat and zoxide. Add them gradually, one or two a week, until they become habit. And if you'd like a team that brings this kind of efficiency to building your product, I'd love to build it with you and my team.
Tags: Terminal, zsh, Productivity, CLI