DEV Community

Binary Journal
Binary Journal

Posted on

Terminal Productivity Tips That Actually Save Time

Stop Typing the Same Commands

If you spend more than a few minutes a day in the terminal, aliases are the lowest hanging fruit. Instead of typing git status a hundred times, make it gst. Instead of docker-compose up, make it dcu. You get the idea.

Add these to your ~/.bashrc or ~/.zshrc:

alias gst='git status'
alias ga='git add'
alias gc='git commit'
alias dcu='docker-compose up'
alias ll='ls -lah'
Enter fullscreen mode Exit fullscreen mode

Don't go overboard. Alias only what you type multiple times a day. If you alias something you use once a week, you'll forget it exists.

Use fzf for Fuzzy Finding

fzf is a command-line fuzzy finder. It lets you search through files, command history, and even git branches with a quick interactive filter. Install it with your package manager, then add these to your shell config:

# Ctrl+R to search history
export FZF_CTRL_R_OPTS='--sort'

# Ctrl+T to search files
export FZF_CTRL_T_COMMAND='rg --files --hidden'

# Use it for git checkout
gitco() {
  local branch=$(git branch --all | fzf | tr -d ' ')
  git checkout "$branch"
}
Enter fullscreen mode Exit fullscreen mode

Now pressing Ctrl+R lets you type a few letters and jump to any command you've run before. That alone saves me minutes every day.

Master the Basics of tmux

tmux is a terminal multiplexer. It lets you split your terminal into panes, keep sessions alive when you disconnect, and manage multiple projects. You don't need to learn everything, just these commands:

tmux new -s work   # start a new session named 'work'
tmux attach -t work # reattach later
Ctrl+b %           # split pane vertically
Ctrl+b "           # split pane horizontally
Ctrl+b d           # detach (session keeps running)
Enter fullscreen mode Exit fullscreen mode

I use tmux every time I work on a remote server. If my SSH connection drops, the session stays alive. I can reconnect and pick up exactly where I left off.

Stop Piping Through grep and cat

Most people do cat file | grep pattern. That's wasteful. Use grep directly:

grep -r "TODO" src/   # recursive search
Enter fullscreen mode Exit fullscreen mode

Also, learn rg (ripgrep). It's faster and has better defaults. If you can't install it, at least use grep -r instead of cat | grep.

Use !! and !$

These two shortcuts are ancient but still useful:

  • !! repeats the last command. Use it when you forget sudo.
  • !$ expands to the last argument of the previous command.
$ mkdir project
$ cd !$   # cd project
Enter fullscreen mode Exit fullscreen mode

Or the classic:

$ apt update
Permission denied
$ sudo !!   # sudo apt update
Enter fullscreen mode Exit fullscreen mode

Make cd Smarter

Stop typing full paths. Use cd - to go back to the previous directory. Use cd ~/projects to jump to a frequent folder. But even better, use z or autojump to jump to directories based on frequency:

# after installing z
z proj   # jumps to ~/projects/my-project
Enter fullscreen mode Exit fullscreen mode

Learn One Text Editor Well

In the terminal, you'll often need to edit files quickly. Learn either vim or nano. I recommend vim because it's everywhere, but if you can't stand it, nano is fine. The key is to know how to:

  • Open a file: vim file.txt
  • Insert mode: press i
  • Save and exit: Esc then :wq
  • Quit without saving: Esc then :q!

That's enough to get by. Once you're comfortable, learn dd to delete a line, yy to copy, and p to paste. Those three commands will cover 80% of what you need.

Use history to Find Commands

Instead of scrolling up, type history and pipe it to grep:

history | grep docker
Enter fullscreen mode Exit fullscreen mode

Or use Ctrl+R if you have fzf installed. Either way, you'll stop repeating yourself.

Customize Your Prompt

A good prompt shows you where you are and what branch you're on. Add this to your ~/.bashrc for a minimal but useful prompt:

PS1='\u@\h:\w$(git_branch_prompt)\$ '
Enter fullscreen mode Exit fullscreen mode

Where git_branch_prompt is a function that prints the current git branch. It's a small change that saves you from typing git branch all day.

Final Tip: Automate the Boring Stuff

If you find yourself running the same three commands in sequence, write a shell script. For example, a script to start a dev environment:

#!/bin/bash
# start-dev.sh
source .env
npm install
docker-compose up -d
npm run dev
Enter fullscreen mode Exit fullscreen mode

Make it executable with chmod +x start-dev.sh, then run ./start-dev.sh. Now one command does what used to take five.

Put It Together

You don't need to adopt everything at once. Pick two or three tips and use them for a week. Once they become muscle memory, add a couple more. Over time, your terminal will feel less like a chore and more like a superpower.

Top comments (1)

Collapse
 
alexshev profile image
Alex Shev

The terminal tips that actually stick are the ones that remove decision friction, not the ones that look clever in a dotfiles screenshot. A few reliable aliases, fast search, history discipline, and project-specific scripts usually beat a huge custom shell setup.