Crates.io | ftdv |
lib.rs | ftdv |
version | 0.1.2 |
created_at | 2025-07-01 14:10:07.005356+00 |
updated_at | 2025-07-02 01:29:40.125992+00 |
description | A terminal-based file tree diff viewer with flexible diff tool integration |
homepage | https://github.com/wtnqk/ftdv |
repository | https://github.com/wtnqk/ftdv |
max_upload_size | |
id | 1733253 |
size | 187,252 |
ftdv (File Tree Diff Viewer) is a terminal-based diff viewer inspired by diffnav and lazygit, built with ratatui in Rust. It combines diffnav's intuitive file navigation with lazygit's flexible diff tool configuration system, providing an interactive interface for viewing git diffs with support for various diff tools like delta, bat, ydiff, and difftastic.
ftdv is a modern TUI diff pager focused on interactive git integration:
ftdv branch1 branch2
)# Install from crates.io
cargo install ftdv
# Or clone and build from source
git clone https://github.com/wtnqk/ftdv.git
cd ftdv
cargo install --path .
# View working directory changes (default)
ftdv
# View staged changes
ftdv --cached
# Compare with a specific commit/branch
ftdv main
# Compare two commits/branches
ftdv main feature-branch
# Compare two files
ftdv file1.txt file2.txt
# Compare two directories
ftdv dir1/ dir2/
# Generate shell completions
ftdv completions bash > ftdv.bash
Key | Action |
---|---|
j / ↓ |
Move down in file list |
k / ↑ |
Move up in file list |
g |
Jump to top of file list |
G |
Jump to bottom of file list |
Key | Action |
---|---|
h / ← |
Scroll diff left (5 chars) |
l / → |
Scroll diff right (5 chars) |
H |
Scroll diff left (20 chars) |
L |
Scroll diff right (20 chars) |
e / J |
Scroll diff down (1 line) |
y / K |
Scroll diff up (1 line) |
d / PageDown |
Scroll diff down (10 lines) |
u / PageUp |
Scroll diff up (10 lines) |
f |
Scroll diff down (20 lines) |
b |
Scroll diff up (20 lines) |
Key | Action |
---|---|
Enter |
Expand/collapse directory |
Space |
Update diff content |
Tab |
Toggle file checkbox |
Key | Action |
---|---|
/ |
Enter search mode |
Enter |
Confirm search (in search) |
Esc |
Exit search mode |
Backspace |
Remove character (in search) |
Key | Action |
---|---|
q |
Quit application |
Esc |
Quit application (if not in search) |
ftdv uses a YAML configuration file located at ~/.config/ftdv/config.yaml
.
# Git paging configuration
git:
paging:
# For stdin/stdout based tools (delta, bat, ydiff)
pager: "command with options"
# For external diff tools (difftastic)
externalDiffCommand: "command with options"
# Color argument passed to git
colorArg: "always"
# Use git's configured pager
useConfig: false
# Theme configuration
theme:
name: dark
colors:
# Color definitions...
git:
paging:
pager: "delta --dark --paging=never --line-numbers --side-by-side -w={{diffAreaWidth}}"
colorArg: "always"
git:
paging:
pager: "bat --style=plain --color=always --terminal-width={{diffAreaWidth}}"
colorArg: "always"
git:
paging:
pager: "ydiff -p cat --color=always --theme=dark --width={{diffAreaWidth}}"
colorArg: "always"
git:
paging:
# Note: difftastic uses externalDiffCommand, not pager
externalDiffCommand: "difft --color=always --background dark --width {{diffAreaWidth}}"
colorArg: "always"
The following template variables (inspired by lazygit's configuration system) can be used in pager and externalDiffCommand strings:
Variable | Description |
---|---|
{{width}} |
Full terminal width |
{{columnWidth}} |
Half terminal width minus padding |
{{diffAreaWidth}} |
Width of the diff display area (80%) |
{{diffColumnWidth}} |
Half of diff area width for side-by-side |
Colors can be specified using:
black
, red
, green
, yellow
, blue
, magenta
, cyan
, white
gray
, dark_gray
light_red
, light_green
, light_yellow
, etc.#ff0000
, #00ff00
, #323264
color0
through color255
theme:
name: dark
colors:
# File tree
tree_line: dark_gray
tree_selected_bg: "#323264"
tree_selected_fg: yellow
tree_directory: blue
tree_file: white
# Status
status_added: green
status_removed: red
status_modified: yellow
# UI
border: dark_gray
border_focused: cyan
title: cyan
status_bar_bg: dark_gray
status_bar_fg: white
# Text
text_primary: white
text_secondary: gray
text_dim: dark_gray
# Background
background: black
theme:
name: light
colors:
tree_selected_bg: "#e6e6fa"
tree_selected_fg: black
tree_directory: blue
tree_file: black
status_added: green
status_removed: red
border: gray
border_focused: blue
text_primary: black
background: white
The distinction is important because:
To add a new diff tool:
# For a pager tool
git:
paging:
pager: "your-tool --option1 --width={{diffAreaWidth}}"
colorArg: "always"
# For an external diff tool
git:
paging:
externalDiffCommand: "your-tool --option1 --width {{diffAreaWidth}}"
colorArg: "always"
ftdv stores persistent data in ~/.local/share/ftdv/
:
pager
or externalDiffCommand
{{diffAreaWidth}}
for most cases{{width}}
for full terminal widthCOLUMNS
environment variablecolorArg: "always"
is setContributions are welcome! Please feel free to submit issues and pull requests.
This project is licensed under either of
at your option.