Terminal Habits That Make You Faster

Learn practical terminal habits with aliases, history search, pipes, safer scripts, rg, fd, and jq.

Terminal Habits That Make You Faster

Everyone who spends the day in the terminal operates in one of two modes. In the slow one, you type every command in full, search your memory for the exact name of that flag, and pray you do not mistype an rm. In the fast one, the machine seems to guess what you want before you finish thinking. The difference is rarely talent—it is a handful of habits that, combined, create speed. Here are the ones that pay off most.

Conveying fluidity and speed while working in the terminal—hands and commands flowing without friction.
Conveying fluidity and speed while working in the terminal—hands and commands flowing without friction.

Aliases and functions: write it once, use it forever

The first rule is simple: if typing something twice feels painful, turn it into a shortcut. Commands you repeat all day deserve an alias.

bash alias gs='git status -sb' alias ll='ls -lah' alias ..='cd ..'

When a command needs arguments, an alias is not enough—use a function.

bash

create the directory and enter it

mkcd() { mkdir -p "$1" && cd "$1"; }

quick git commit with a message

gc() { git commit -m "$*"; }

Put everything in your ~/.bashrc or ~/.zshrc and reload it with source ~/.zshrc. Over the course of months, those saved seconds add up to hours—and, more importantly, remove friction between an idea and its execution.

Never type the same command twice

You already ran that huge command yesterday. Do not type it again: Ctrl-R opens a reverse search through your history. Start typing part of it and the shell completes it with the most recent match; press Ctrl-R again to move backward through previous matches.

If you install fzf, Ctrl-R becomes a navigable fuzzy list of your entire history—the difference is striking. Two everyday shortcuts:

bash !! # repeat the last command sudo !! # repeat the last command, now with sudo

The second one solves the classic “oh, it needed permission” problem without making you retype anything.

Composing commands: pipes and xargs

The Unix philosophy is built around small tools that do one thing well and fit together. The pipe (|) passes one command’s output as the next command’s input; xargs takes those lines and turns them into arguments for another command.

bash

how many lines are in all files that mention TODO?

grep -rl TODO . | xargs wc -l

compress each .log file found, one at a time

find . -name '*.log' | xargs -I{} gzip {}

Mastering this kind of composition is worth more than memorizing a hundred flags: you assemble the right tool on the spot by fitting together pieces you already know.

Destructive commands without surprises

Speed without care becomes a disaster. Before deleting anything, see what you are about to delete: run find or ls first, check the list, and only then replace it with rm. Use -i to confirm files one by one, and prefer --dry-run whenever the tool provides it.

The greatest danger is rm -rf with an empty variable—an undefined $DIR can turn into rm -rf /. Protect yourself with an expansion that fails if the variable is empty:

bash rm -rf "${BUILD_DIR:?must be defined}/dist"

If BUILD_DIR does not exist, the command aborts with a clear message instead of destroying files. A small habit, averted catastrophe.

Scripts that do not betray you: set -euo pipefail

The moment you paste commands into a .sh file, you become a software author—and silent software is dangerous software. Start every script like this:

bash

!/usr/bin/env bash

set -euo pipefail

In plain English: -e makes the script stop at the first command that fails instead of continuing to dig; -u turns an undefined variable into an error (goodbye, silent typos); and pipefail makes an error in the middle of a pipe count as a failure instead of being swallowed by the last command. Three words that separate a reliable script from a time bomb.

Replace the old toolkit with rg, fd, and jq

grep and find work, but the ecosystem has evolved. It is worth adopting:

  • ripgrep (rg) — searches text while respecting .gitignore, with colored output and much greater speed.
  • fd — finds files with human-friendly syntax, without the gymnastics of quotes and -name in find.
  • jq — slices and filters JSON like a scalpel, essential for working with APIs in the terminal.

bash rg 'TODO' --type py fd '.env' curl -s https://api.exemplo.com/itens | jq '.items[].name'

You do not need to replace everything at once: install one, use it for a week, and you will not go back.


Do not try to absorb all six habits today. Choose one—probably Ctrl-R or a couple of aliases—and use it until it becomes second nature. A fast terminal is not a gift that some people have and others do not; it is built through repetition. One layer per week, and in a month your hands will move faster than your head.

Did you enjoy this article?

Share it with your friends and help spread knowledge!