Next-Level Terminal Productivity: tmux, Command Chains, and Hidden Gems

In my previous article on terminal keyboard shortcuts, I shared some techniques to help you navigate the command line more efficiently. This is actually the third in my terminal productivity series, following my earlier post on terminal productivity tips for web developers. Today, I want to take things a step further and introduce some powerful terminal tools that will seriously level up your productivity. If you're anything like me, you spend a significant portion of your day in the terminal, so even small efficiency gains add up to a substantial time-saving over the months and years.

We'll start with tmux (a terminal multiplexer that will change how you work), then explore some lesser-known but incredibly practical commands, and finally look at how to chain commands together for maximum effect. Let's dive in!

tmux - The Terminal Multiplexer You Need

If you've ever SSH'd into a server, started a long-running task, and then accidentally closed your terminal (or lost your connection), you'll understand why tmux is essential. But it's much more than just a session persistence tool.

At its core, tmux allows you to:

  • Run multiple terminal sessions within a single window
  • Detach from and reattach to sessions (even after disconnections)
  • Split your terminal into panes with different commands
  • Switch between multiple terminal windows
  • Create a consistent workspace that remains exactly as you left it

Here's a quick-start guide to get you up and running:

# Install tmux
sudo apt install tmux    # On Ubuntu/Debian
brew install tmux        # On macOS with Homebrew

# Start a new session
tmux

# Detach from session (without closing it)
# Press Ctrl+b, then d

# List existing sessions
tmux ls

# Reattach to a session
tmux attach -t 0    # Attach to session 0

The real power of tmux comes from its keyboard shortcuts. All tmux commands start with the prefix key combo (by default, Ctrl+b), followed by another key:

  • Ctrl+b c - Create a new window
  • Ctrl+b % - Split the current pane vertically
  • Ctrl+b " - Split the current pane horizontally
  • Ctrl+b arrow key - Move between panes
  • Ctrl+b n - Move to the next window
  • Ctrl+b p - Move to the previous window
  • Ctrl+b d - Detach from the current session

I use tmux daily for managing multiple tasks. For example, when I'm working on a web project, I might have one pane running a local server, another watching for file changes, a third for git commands, and a fourth for editing config files. All of this in a single terminal window that I can detach from and return to exactly as I left it.

Lesser-Known Terminal Commands You Should Be Using

While everyone knows cd, ls, and grep, there are dozens of lesser-known commands that can dramatically improve your workflow. Here are some of my favorites:

1. xargs - Transform your command pipeline

If you're tired of writing complex loops to process multiple files, xargs is about to become your new best friend:

# Batch rename files from .txt to .md
find . -name "*.txt" | xargs -I{} mv {} {}.md

# Process multiple files in parallel (4 at a time)
find . -name "*.png" | xargs -P 4 -I{} convert {} {}.jpg

# Create directories from a list
cat directories.txt | xargs mkdir -p

# Find and replace in multiple files
grep -l "oldtext" * | xargs sed -i 's/oldtext/newtext/g'

2. pv - Monitor progress through pipelines

When dealing with large files or long-running operations, pv (pipe viewer) is invaluable:

# Show progress while copying a large file
dd if=/dev/urandom | pv | dd of=largefile bs=1M count=1000

# Monitor download progress
wget -O - https://example.com/largefile.iso | pv > largefile.iso

# Show transfer rate and ETA
cat largefile | pv -s 5G | gzip > largefile.gz

3. bat - cat with syntax highlighting

Once you use bat instead of cat, you'll never go back:

# View a file with syntax highlighting
bat script.js

# Use as a colorizing pager
curl -s https://api.example.com/data | bat --language json

4. jq - Parse and manipulate JSON

Working with JSON on the command line was a pain until jq came along:

# Pretty-print JSON
curl -s https://api.github.com/repos/torvalds/linux | jq

# Extract specific fields
cat data.json | jq '.items[].name'

# Filter JSON data
cat users.json | jq '.[] | select(.age > 30)'

5. ncdu - Interactive disk usage analyzer

When you need to free up disk space, ncdu is far more useful than du:

# Analyze disk usage in current directory
ncdu

# Analyze a specific directory
ncdu /var/log

The interactive interface makes it easy to spot the largest files and directories, and you can delete them right from the interface.

Chaining Commands for Maximum Efficiency

One of the most powerful aspects of the Unix philosophy is the ability to chain together simple commands to create complex operations. Here are some of my favorite command chains:

Find and replace text across multiple files

# Find all JavaScript files containing "oldFunction" and replace with "newFunction"
grep -l "oldFunction" --include="*.js" -r . | xargs sed -i 's/oldFunction/newFunction/g'

Process images in bulk

# Find all PNG files and convert them to WebP format
find . -name "*.png" | xargs -P 4 -I{} sh -c 'cwebp {} -o {}.webp'

Monitor a command's output in real-time with useful formatting

# Watch log file with timestamps and highlight errors
tail -f app.log | grep --line-buffered -E '^|ERROR|WARN' | ts '%H:%M:%S'

Create a compressed backup of recent files

# Backup all files modified in the last day
find . -mtime -1 | xargs tar -czvf recent_changes.tar.gz

Why These Tools Matter

You might be thinking, "Do I really need to learn yet another set of terminal commands?" The answer is a resounding yes, and here's why:

  1. Time investment versus return: The time you spend learning these tools will be repaid many times over through daily productivity gains.
  2. Terminal work is unavoidable: If you're in web development, DevOps, data science, or almost any technical field, terminal work is unavoidable. You might as well make it as efficient as possible.
  3. Universality: Most of these tools work across different operating systems and environments. Learn once, use everywhere.

Where to Start?

If I had to recommend just three tools to start with, I'd suggest:

  1. tmux - For session management and pane splitting
  2. xargs - For building powerful command pipelines
  3. jq - For working with JSON data

These three alone will give you a significant productivity boost with minimal learning curve.

Final Thoughts

Don't try to master all these tools at once. Instead, start with one that solves a particular pain point in your workflow. Use it consistently for a week. Then add another. Before you know it, your terminal productivity will be supercharged, and you'll wonder how you ever worked without these tools.

What are your favorite terminal productivity tools? Let me know in the comments below!