Start of heading level 1: Code Presentation at the Next Level: bat and delta in the Terminal End of heading.

Anyone who spends a lot of time in the console knows the classics: cat for quickly viewing files and git diff for checking code changes. Both have served their purpose for decades, but visually they remain stuck in the past. Yesterday, I discovered two modern CLI tools and immediately installed them on my system to replace these classics: bat and delta.

Both tools are written in Rust, extremely performant, and elevate the rendering of code to a whole new level. Here is my tool presentation and how I have seamlessly integrated them into my Zsh and Git configurations.

Start of heading level 2: 🦇 bat: A cat Clone on Steroids End of heading.

bat is a modern replacement for the standard cat command. While cat simply dumps raw text to the terminal, bat shines with several handy features:

  • Syntax Highlighting: Supports a wide range of programming and markup languages out of the box.
  • Git Integration: Shows modified lines in the left gutter (added +, modified ~, or deleted - lines) relative to the last Git commit.
  • Line Numbers: Makes reading and referencing specific lines of code much easier.
  • Automatic Paging: If a file is longer than the screen, bat automatically pipes the output to a pager (like less), allowing you to scroll and search comfortably.

A simple invocation is all it takes:

bat index.en.md

Start of heading level 2: 📐 delta: Perfect Diffs for Git End of heading.

If you regularly review code or inspect your own changes, you’ll be familiar with git diff. The default output is functional but can quickly get confusing, especially with complex changes. This is where delta (also known as git-delta) comes in.

delta acts as a pager for Git output. It reads standard diffs and formats them visually:

  • Intra-line Highlighting (Word-level diffs): It doesn’t just highlight modified lines; it also uses a more intense color to highlight the exact words that changed.
  • Syntax Highlighting in Diffs: Even within a diff, the code is colored according to the programming language.
  • Line Numbers & Side-by-Side View: Supports showing diffs in two columns side-by-side as well as clean, separate line number columns for old and new versions.

Start of heading level 3: My Git Configuration End of heading.

I configured delta globally in my ~/.gitconfig:

[core]
	pager = delta
[interactive]
	diffFilter = delta --color-only
[delta]
	navigate = true
	light = false
	line-numbers = true
[merge]
	conflictstyle = zdiff3

What do these settings mean in detail?

  1. core.pager = delta: Routes all Git output (such as git diff or git log) through delta by default.
  2. interactive.diffFilter = delta --color-only: Ensures that the beautiful color formatting is preserved even when staging changes interactively (git add -p).
  3. delta.navigate = true: Enables navigating between changed code blocks (hunks) in the pager using the n and N keys.
  4. delta.light = false: Optimizes the color scheme for a dark terminal theme.
  5. delta.line-numbers = true: Activates classic line numbers in the diff output, making orientation much easier.
  6. merge.conflictstyle = zdiff3: This is a modern Git conflict style. In case of a conflict, it shows the common ancestor version alongside your changes and their changes. delta formats these three-part conflicts beautifully, making conflict resolution much less stressful.

Start of heading level 2: 🐚 Zsh Integration: Smart Overriding for cat and diff End of heading.

Using standard shell aliases like alias cat="bat" can break scripts or pipelines, as tools that process the text output of cat are usually not prepared for ANSI color escape sequences or line numbers. My solution is dynamically loading custom Zsh functions (using autoload in my ~/.zshrc).

Start of heading level 3: 1. Smart cat End of heading.

My custom Zsh function checks if stdout is a terminal/TTY ([[ -t 1 ]]). Only then does it execute bat. For pipelines (e.g., cat file.txt | grep ...), it automatically falls back to standard cat to keep things compatible:

if [[ -t 1 ]] && command -v bat >/dev/null 2>&1; then
    bat "$@"
else
    command cat "$@"
fi

Start of heading level 3: 2. Side-by-Side diff End of heading.

Similarly, the diff command is overridden. If run directly in the terminal, it utilizes the side-by-side view of delta. Otherwise, it falls back to the original GNU diff:

if [[ -t 1 ]] && command -v delta >/dev/null 2>&1; then
    delta --side-by-side "$@"
else
    command diff "$@"
fi

Start of heading level 2: 🌐 HTML Diffs at Your Fingertips: htmldiff End of heading.

As a handy addition, I use a Zsh helper function called htmldiff. It generates a colorful, side-by-side HTML comparison of any two files and saves it to disk (ideal for sharing diffs via email or viewing them in a browser).

It achieves this by combining delta with the utility ansifilter:

# Zsh-Funktion: htmldiff
# Erstellt einen farbigen HTML-Diff von zwei Dateien mittels delta und ansifilter.
local fileA="$1"
local fileB="$2"

# ... (checks for files and tools existence) ...

local timestamp
zmodload zsh/datetime
strftime -s timestamp "%Y%m%d%H%M%S"

local nameA="${fileA:t}"
local nameB="${fileB:t}"
local outfile="${nameA}_${nameB}_diff_${timestamp}.html"

# Generate diff with delta and save as HTML via ansifilter
delta -s --light --no-gitconfig --file-decoration-style blue --hunk-header-decoration-style blue "$fileA" "$fileB" | ansifilter --html --encoding=utf-8 > "$outfile"

The --light flag ensures that the generated HTML is perfectly readable against the browser’s default light background.


Start of heading level 2: Conclusion: Is the Switch Worth It? End of heading.

Absolutely. If you spend a lot of time in the terminal, you will benefit greatly from the improved readability. Since both bat and delta are written in Rust, there is no noticeable overhead or delay – the tools feel just as fast as their decades-old predecessors but bring the comfort of a modern IDE right to your command line, without breaking old pipelines.

Do you already use modern alternatives to the classic Unix utilities? Let me know in the comments!

73 de DO3EET

×
Achievement Unlocked

Lang verschollenen Tux gefunden
Der Geist der CLT2026 lebt! 🐧✨

Ich bin Frank. Ein Informatiker und Funkamateur aus Deutschland. Außerdem reise ich gern nach Japan.


By Frank Tornack, 2026-06-16

×
Achievement Unlocked

Screen Burn-In
Glückwunsch! Deine Pixel sind jetzt offiziell eins mit meiner Website. 📺✨