# The Modern Terminal Stack

## Unix didn’t need replacing. Its interface just needed better parts.

The Unix command line has survived for more than half a century because its central idea is remarkably durable: small tools, plain text, pipelines, composition.

That does not mean you have to use the same tools people were using in 1987.

A modern terminal environment can still look and behave like Unix while being dramatically faster to navigate. Search can be instantaneous. History can be fuzzy. Git diffs can be readable. Directory changes can remember where you actually go. Long-running sessions can survive network disconnects. JSON can become just another stream of text.

The trick is not replacing the shell with some gigantic integrated environment. It is assembling a better set of small tools around it.

Think of it as a modern Unix workstation built inside the terminal.

---

# Start With the Shell

You do not need a fashionable shell to build a good terminal environment.

`sh`, `ksh`, `mksh`, `bash`, and `zsh` are all perfectly capable foundations. Fish provides a more opinionated interactive experience, but it deliberately differs from POSIX shell syntax.

The important distinction is between the shell as a programming language and the shell as an interactive interface.

Scripts benefit from conservative, portable syntax.

Humans benefit from aggressive convenience.

That means keeping shell scripts boring while making your interactive terminal fast, searchable, persistent, and pleasant.

Everything else in this stack builds on that distinction.

---

# ripgrep: grep at Human Speed

For decades, recursively searching a source tree often meant some variation of:

```sh
grep -R "socket" .
```

Or worse:

```sh
find . -type f -exec grep "socket" {} \;
```

`ripgrep`, invoked as `rg`, turns recursive searching into something you can do almost without thinking.

```sh
rg socket
```

By default it recursively searches the current directory, ignores binary files, respects `.gitignore`, and produces readable output.

Searching only C files:

```sh
rg 'malloc\(' -g '*.c'
```

Ignoring case:

```sh
rg -i freebsd
```

Showing surrounding lines:

```sh
rg -C 3 'panic'
```

Searching filenames rather than contents:

```sh
rg --files
```

That last command becomes especially important once `fzf` enters the picture.

`grep` remains one of Unix's fundamental tools. `rg` does not invalidate it. Instead, ripgrep optimizes the extremely common modern case: interactively searching large directory trees and source repositories.

For quick exploratory work, `rg` becomes muscle memory.

---

# fzf: Make Everything Searchable

`fzf` is a fuzzy finder.

That description drastically undersells it.

At its simplest:

```sh
printf '%s\n' *
```

produces a list.

Pipe the list into `fzf`:

```sh
printf '%s\n' * | fzf
```

and it becomes an interactive searchable list.

That means practically anything capable of producing lines of text can become a user interface.

Combine it with ripgrep:

```sh
rg --files | fzf
```

You now have an interactive file finder.

Open the selected file:

```sh
vi "$(rg --files | fzf)"
```

Search Git branches:

```sh
git branch --format='%(refname:short)' | fzf
```

Search running processes:

```sh
ps aux | fzf
```

Search SSH hosts, manual pages, package names, bookmarks, command history, kernel symbols, ZFS datasets, jails, containers, or anything else you can express as lines of text.

This is where `fzf` becomes more than a utility.

It is an interface primitive.

Traditional Unix tools give you producers and consumers. `fzf` inserts a human decision in the middle of the pipeline.

```text
producer | fzf | consumer
```

That pattern can replace an astonishing amount of custom UI.

---

# Ctrl-R Should Not Be Archaeology

Traditional shell history search works, but once your history grows into tens or hundreds of thousands of commands, repeatedly pressing Ctrl-R starts to feel absurd.

The modern version looks more like this:

```text
Ctrl-R
→ fuzzy search all previous commands
→ type two fragments
→ Enter
```

With `fzf`, shells such as bash and zsh can turn history into an interactive searchable database.

Instead of remembering:

```text
Was that command rsync --archive first, or ssh first?
```

you remember fragments:

```text
rsync backup nas
```

and let fuzzy matching recover the exact command.

This changes the economics of shell history.

History stops being a small convenience and becomes accumulated operational knowledge.

A useful command you wrote six months ago no longer needs to live in a text file called `notes-final-2.txt`.

Your history is the notebook.

---

# tmux: The Terminal Is the Desktop

If the shell is your primary interface, eventually a single terminal window stops being enough.

That is where `tmux` fits.

A tmux session can contain multiple windows. Each window can contain multiple panes. More importantly, the entire session continues running independently of the terminal connected to it.

Start one:

```sh
tmux
```

Disconnect.

SSH somewhere else.

Reconnect:

```sh
tmux attach
```

Everything is still there.

That makes tmux valuable locally, but invaluable remotely.

An interrupted SSH connection no longer means a lost editor session, interrupted build, or vanished debugging state.

A typical workspace might look like:

```text
┌─────────────────────────────┐
│            vim              │
│                             │
├──────────────────┬──────────┤
│ build / tests    │ logs     │
│                  │          │
└──────────────────┴──────────┘
```

The temptation is to spend days customizing tmux.

Resist it initially.

Learn sessions, windows, panes, detach, and attach.

That alone delivers most of the value.

---

# fd: find for Interactive Use

`find` is extraordinarily powerful.

It also has syntax like this:

```sh
find . -type f -name '*.c'
```

For scripts, that explicitness is often desirable.

For interactive use, `fd` optimizes the common cases:

```sh
fd '\.c$'
```

Find directories:

```sh
fd --type d
```

Include hidden files:

```sh
fd --hidden
```

Like ripgrep, it normally respects ignore files and avoids descending into directories you almost certainly did not intend to search.

And naturally:

```sh
fd | fzf
```

For portable scripts, learn `find`.

For finding something while your hands are on the keyboard, `fd` is hard to beat.

---

# bat: cat With Context

`cat` does one thing extremely well.

`bat` answers a somewhat different question:

> What if I want to look at this file?

```sh
bat main.c
```

It adds syntax highlighting, paging, line numbers, and Git-aware annotations.

It can also integrate naturally with `fzf`.

For example, an interactive file selector can show file contents in a preview pane while you move through the search results.

Conceptually:

```sh
fzf --preview 'bat --color=always {}'
```

Now your file picker is not merely searching filenames. It is showing you the file before you open it.

This is an important pattern in the modern terminal stack:

**selection plus preview.**

Fuzzy finding becomes significantly more powerful when candidates are cheap to inspect.

---

# zoxide: Stop Typing Paths

Unix gives every directory a location.

Humans do not think in absolute paths.

You think:

> Go to the source tree.

Not:

```sh
cd ~/work/projects/example/src/backend/server
```

`zoxide` learns the directories you visit and lets you jump to them using fragments.

Instead of:

```sh
cd ~/src/freebsd/sys/amd64/amd64
```

you might type:

```sh
z amd64
```

Its database gradually reflects your habits, making commonly visited directories easier to reach.

It is essentially shell navigation with memory.

Once you become accustomed to this model, deeply nested paths begin to feel like implementation details.

---

# jq: JSON Becomes Unix Text

Modern systems constantly emit JSON.

Unix tools were designed around streams of text.

`jq` connects those worlds.

Given:

```json
{
  "users": [
    {"name": "alice", "shell": "/bin/sh"},
    {"name": "bob", "shell": "/bin/ksh"}
  ]
}
```

you can write:

```sh
jq -r '.users[].name'
```

and get:

```text
alice
bob
```

Now every old Unix tool works again.

```sh
curl ... |
    jq -r '.users[].name' |
    sort |
    uniq
```

The significant thing about jq is not simply that it parses JSON.

It converts structured application data back into material suitable for pipelines.

In a world full of HTTP APIs and machine-readable command output, that makes jq one of the defining Unix tools of the modern era.

---

# delta: Make Git Diffs Legible

Git is already a command-line application, but some of its default output feels more optimized for machines than humans.

`delta` acts as a pager for Git diffs, adding clearer formatting, syntax highlighting, line numbers, and improved visual structure.

Instead of replacing Git, it improves one of Git's interfaces.

That distinction recurs throughout this stack.

`bat` does not replace files.

`fzf` does not replace lists.

`ripgrep` does not replace regular expressions.

`delta` does not replace Git.

These tools make existing Unix workflows easier for humans to operate.

---

# direnv: Environment Per Directory

Development environments accumulate environment variables.

You enter a project and need:

```sh
export API_URL=...
export GOPATH=...
export PATH=...
```

You leave it, and those values are still hanging around.

`direnv` associates environment changes with directories.

Enter the project:

```text
environment loaded
```

Leave the directory:

```text
environment unloaded
```

This is particularly useful when working across many projects or language environments.

It also follows a deeper Unix principle: context should come from the filesystem whenever practical.

The directory itself becomes part of the environment.

---

# The Stack Becomes More Than Its Parts

Individually, none of these applications radically changes Unix.

Together, they do.

Consider finding a piece of code.

Old workflow:

```text
cd around
find something
grep something
less something
open editor
```

Modern workflow:

```text
rg → fzf → preview → editor
```

Finding an old command:

```text
history → fzf → execute
```

Navigating somewhere:

```text
z fragment
```

Working remotely:

```text
ssh → tmux attach
```

Inspecting an API:

```text
curl → jq → fzf
```

The difference is not merely fewer keystrokes.

The terminal becomes interactive without abandoning pipelines.

That is the important part.

---

# Don't Alias Away Unix

There is a tendency to install these programs and immediately write:

```sh
alias grep=rg
alias cat=bat
alias find=fd
alias cd=z
```

That can be convenient, but it also obscures meaningful differences.

`rg` is not exactly `grep`.

`fd` is not exactly `find`.

`bat` is not exactly `cat`.

And scripts copied from your interactive shell may eventually run somewhere those tools do not exist.

A cleaner approach is to retain both vocabularies.

Know Unix:

```text
grep
find
cat
cd
vi
```

Use modern interactive tools when they improve the experience:

```text
rg
fd
bat
z
fzf
```

Portable primitives underneath.

Fast human interfaces on top.

---

# A Sensible Starter Stack

You do not need fifty terminal utilities.

Start with five:

```text
ripgrep    search text
fzf        search choices
tmux       preserve workspaces
bat        inspect files
zoxide     navigate directories
```

Then add:

```text
fd         interactive file discovery
jq         structured data
delta      readable Git diffs
direnv     directory environments
```

The goal is not to collect programs.

It is to remove friction.

Whenever you repeatedly find yourself navigating a long path, searching through output manually, rebuilding a lost session, scrolling through history, or visually parsing machine-oriented text, there is probably a composable tool that can remove that friction.

---

# Unix, Upgraded

The interesting thing about this toolchain is how little it changes the fundamental Unix model.

You still have files.

You still have processes.

You still have standard input and output.

You still have pipes.

You still have a shell.

The modern terminal stack simply recognizes that the person sitting at the keyboard is also part of the pipeline.

Tools like `fzf` let the human select.

`bat` and `delta` help the human see.

`zoxide` remembers where the human goes.

`tmux` preserves the human's working state.

`ripgrep` makes enormous collections of text searchable at interactive speed.

The result feels surprisingly modern without requiring Unix to become something else.

That may be the strongest evidence that the original architecture got something right.

Half a century later, we are still not replacing the pipeline.

We are just making it faster.
