purefetch 0.2.3

A fast, fastfetch-style system information tool written entirely in Rust with zero dependencies
# purefetch

[![CI](https://github.com/ooonea/purefetch/actions/workflows/ci.yml/badge.svg)](https://github.com/ooonea/purefetch/actions/workflows/ci.yml)
[![crates.io](https://img.shields.io/crates/v/purefetch.svg)](https://crates.io/crates/purefetch)
[![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](#license)
![Rust](https://img.shields.io/badge/rust-1.70%2B-orange.svg)
![Dependencies: 0](https://img.shields.io/badge/dependencies-0-brightgreen.svg)

A small, fast system-information tool — a [fastfetch](https://github.com/fastfetch-cli/fastfetch)-style
fetcher written **entirely in Rust with zero external crates**.

No `libc`, no `sysinfo`, no `nix`, no color crate — nothing from crates.io.
On **Linux**, the handful of syscalls that have no `std` wrapper (`statfs`,
`ioctl` for the terminal size / tty check, `kill` for command process groups)
are issued directly as raw syscalls
(x86_64, aarch64, riscv64 and loongarch64) via `core::arch::asm!`; everything
else is `std` plus parsing of `/proc` and `/sys`. On **macOS**, where raw
syscalls are not a stable ABI, the same platform layer binds `extern "C"`
straight to libSystem (statfs, sysctl, mach VM statistics, libproc) — which
Rust's `std` already links — so the crate stays free of external dependencies
there too. It builds offline and has a trivial dependency graph.

<p align="center"><img src="assets/purefetch.svg" alt="purefetch running on NixOS" width="680"></p>

```
         -##=      =###+   =##-            ooonea@unicorn
         *@@@*      *@@@*.+@@@*            ──────────────
          +@@@#.     +@@@@@@@*             OS            NixOS 26.05 (yarara) x86_64
      *%%%%@@@@%%%%%%#+@@@@@=              Host          ThinkPad P53 (20QQS0JD01)
    .#@@@@@@@@@@@@@@@@%+%@@@-    .*.       Kernel        6.18.52
     .....=###*.........:%@@@=  :%@%:      Uptime        11 hours, 4 mins
         +@@@#.          .#@@@=-@@@%:      Shell         zsh 5.9.1
 .......*@@@*.             *@#*@@@%:...    Display       1920x1080 (eDP-1)
+@@@@@@@@@@+                =*@@@@@@@@@+   DE            umbriel
-#%%%%@@@@+*.              .#@@@%%%%%%#-   Terminal      kitty 0.48.2
    :%@@@+%@%.            .%@@@=           CPU           Intel(R) Core(TM) i7-9850H @ 4.60 GHz
   -@@@%:-@@@%:          :%@@@-            GPU           Quadro RTX 3000
   .*@#.  :%@@@-:--------*###+-----.       Memory        22.50 GiB / 62.61 GiB (36%)
     =.    .%@@@*#@@@@@@@@@@@@@@@@*        Swap          0 B / 15.65 GiB (0%)
           *@@@@@*+*****#@@@@****=         Disk (zroot)  293.35 GiB / 928.00 GiB (32%)
         .#@@@#@@@#.     +@@@#.            Locale        C.UTF-8
         #@@@= =@@@%.     =@@@#            Battery       80% (Not charging)
         .==:   -====      :==.
```

## Install

With a Rust toolchain (1.70+):

```sh
cargo install purefetch
```

Or straight from the repo (latest `main`):

```sh
cargo install --git https://github.com/ooonea/purefetch
```

Or build from source:

```sh
git clone https://github.com/ooonea/purefetch
cd purefetch
cargo build --release
./target/release/purefetch
# optional: install to ~/.cargo/bin
cargo install --path .
```

### With Nix

```sh
nix run github:ooonea/purefetch
```

Or add the flake as an input and use `purefetch.packages.${system}.default`
(built for `x86_64-linux`, `aarch64-linux`, `aarch64-darwin` and
`x86_64-darwin`; there is also an `overlays.default`).

Targets **Linux** on **x86_64**, **aarch64**, **riscv64**, and **loongarch64**,
and **macOS** (Apple Silicon and Intel).

## Usage

```
purefetch [OPTIONS]

-l, --logo <NAME>       logo: auto (default), or a distro name (see below)
    --logo-file <PATH>  use a custom logo, read verbatim from a file
    --logo-exec <CMD>   use a custom logo from a command's output (dynamic)
    --modules <LIST>    comma-separated modules to show ('-' = separator)
    --exec <LABEL:CMD>  add a custom line from a shell command (ref in --modules)
    --config <PATH>     read options from PATH
    --no-config         ignore any config file
    --no-logo           do not print any logo
    --no-color          disable ANSI colors
    --no-color-blocks   hide the trailing ANSI color blocks
-V, --version           print version and exit
-h, --help              print this help and exit
```

Colors are disabled automatically when stdout is not a terminal (or when
`NO_COLOR` is set), so `purefetch | cat` produces clean, unstyled text.

Bundled logos: `arch`, `ubuntu`, `fedora`, `debian`, `mint`, `manjaro`, `pop`,
`opensuse`, `alpine`, `void`, `nixos`, `gentoo`, `endeavouros`, `kali`,
`elementary`, `zorin`, `artix`, `rocky`, `almalinux`, `centos`, `devuan`, `mx`,
`garuda`, `macos` (alias `apple`), `tux` (and `none`). `auto` picks one from
`/etc/os-release` on Linux (falling back to `tux`) and always the Apple logo
on macOS. Use `--logo nixos_small` for the compact, 20-column NixOS variant.

## Configuration

Any option can also live in a config file — one `key value` per line — so plain
`purefetch` reproduces your setup (a login banner and an interactive prompt then
show the same thing):

```
# ~/.config/purefetch/config
logo-exec /home/me/.config/purefetch/gen-logo.sh
no-color-blocks
modules os,host,kernel,-,cpu,memory,swap,-,shell
exec Pool:zpool list -H -o health,cap zroot
```

purefetch reads `$PUREFETCH_CONFIG`, then `~/.config/purefetch/config`, then
`/etc/purefetch/config`. Command-line flags override the file; `--no-config`
ignores it.

Repeated `exec` labels are case-insensitive; the last definition wins, including
when a command-line definition replaces one from the config file.

External commands (including `exec` and `logo-exec`) have a two-second deadline;
failed or timed-out commands produce no data.

## Detected info

`Title (user@host)`, `OS`, `Host`, `Kernel`, `Uptime`, `Packages`, `Shell`,
`Display`, `DE`, `WM`, `Terminal`, `CPU`, `GPU`, `Memory`, `Swap`, `Disk (/)`,
`Locale`, `Battery`, and the ANSI color blocks. Any module whose data is
unavailable (e.g. `Battery` on a desktop, `Swap` with no swap) is silently
skipped.

## Notable details

- **Zero dependencies.** The whole tool is `std` + the platform layer in
  `src/sys/` (raw syscalls on Linux, libSystem FFI on macOS).
- **ZFS-aware.** `Memory` is `MemTotal - MemAvailable` (matching `free`/htop) — the
  ARC counts as used because it genuinely occupies RAM. On a ZFS root, `Disk` reports
  the whole pool via `zpool list` (labelled `Disk (<pool>)`), not just the root
  dataset's few GiB.
- **macOS semantics match the natives.** `Memory` follows `vm_stat`/Activity
  Monitor (total minus really-free and file-backed pages), `Disk (/)` reports
  the shared APFS container with used = total - available (like fastfetch),
  `Display` lists native pixels via CoreGraphics, and `Host` shows the device
  tree's marketing name over the board id — no model lookup table to age.
- **Process-parent detection.** `Shell` and `Terminal` walk the parent chain
  (`/proc/<pid>/stat`+`comm` on Linux, `proc_pidinfo` on macOS), with
  environment-variable fallbacks (`$TERM`, `$TERM_PROGRAM`,
  `$KITTY_WINDOW_ID`, ...) for the terminal.
- **Best-effort detection.** Missing data drops its line; external command
  probes time out after two seconds.

## Architecture

```
src/
  main.rs        arg parsing, module ordering, title/separators/color blocks, dispatch
  sys/
    mod.rs       platform-layer API (disk_usage, term_width, hostname, ppid_comm, ...)
    linux.rs     raw Linux syscalls (x86_64, aarch64, riscv64, loongarch64): statfs, ioctl, kill
    darwin.rs    libSystem FFI: statfs, sysctl, mach VM stats, libproc, CoreGraphics
  util.rs        file helpers, subprocess helper, byte/percent formatting
  color.rs       ANSI palette
  logo.rs        OS ASCII logos + selection (generated by examples/genlogos.rs)
  render.rs      logo-left / info-right layout, ANSI-aware width & truncation
  detect/
    mod.rs       Row/Rows contract + module registry
    *.rs         one module per info line (os, cpu, gpu, memory, ...), cfg-split per OS
```

Adding an info source is one file: implement
`pub fn detect() -> crate::detect::Rows` in `src/detect/<name>.rs` and register
it in `src/main.rs`. Adding a distro logo is one text file in `assets/logos/`
followed by `cargo run --example genlogos`.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md). New distro logos, more package managers,
extra info modules, and support for other CPU architectures are all welcome —
please keep the zero-dependency rule and run `cargo fmt` before submitting.

## Disclosure

purefetch was built largely with **AI assistance** (Claude Code). The design was
human-directed and every change was reviewed and tested — including running the
tool on all four supported architectures under QEMU — but most of the code is
AI-generated. Noting it openly so you know how it was made.

## Credits

The bundled logos are traditional ASCII adaptations of the projects' original
artwork. Sources, authors and separate artwork terms are listed in
[CREDITS.md](CREDITS.md). Names and marks identify the reported operating system;
they do not imply endorsement of purefetch.

## License

The program code is licensed under either of

- MIT license ([LICENSE-MIT](LICENSE-MIT))
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))

at your option. Logo artwork retains the separate terms in [CREDITS.md](CREDITS.md).

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.