Convert Figma logo to code with AI

Byron logodua-cli

View disk space usage and delete unwanted data, fast.

3,931
108
3,931
23

Top Related Projects

8,538

A more intuitive version of du in rust

12,655

Disk Usage/Free Utility - a better 'df' alternative

33,285

A simple, fast and user-friendly alternative to 'find'

47,483

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

Quick Overview

Dua-cli is a command-line tool written in Rust for efficiently analyzing disk usage. It provides a fast and interactive way to view and understand how space is used on your storage devices, offering both a terminal user interface and command-line options for various use cases.

Pros

  • Extremely fast performance, especially on SSDs
  • Interactive terminal user interface for easy navigation
  • Supports aggregation of file sizes for quick overview
  • Cross-platform compatibility (Windows, macOS, Linux)

Cons

  • Requires Rust runtime environment for installation from source
  • May have a learning curve for users unfamiliar with command-line tools
  • Limited graphical visualization compared to some GUI alternatives

Getting Started

To install dua-cli, you can use one of the following methods:

  1. Using Cargo (Rust's package manager):

    cargo install dua-cli
    
  2. On macOS using Homebrew:

    brew install dua-cli
    
  3. On Windows using Scoop:

    scoop install dua-cli
    

Once installed, you can start using dua-cli with the following basic commands:

  • To analyze the current directory:

    dua
    
  • To launch the interactive terminal user interface:

    dua i
    
  • To get an aggregate view of a specific directory:

    dua /path/to/directory
    

For more advanced usage and options, refer to the project's documentation on GitHub.

Competitor Comparisons

8,538

A more intuitive version of du in rust

Pros of dust

  • More visually appealing output with colorful bar charts
  • Offers additional sorting options (e.g., by file count, apparent size)
  • Includes a "file type" view for analyzing disk usage by file extension

Cons of dust

  • Slightly slower performance on large directories
  • Less detailed information about individual files
  • No built-in interactive mode for navigating directories

Code comparison

dust:

pub fn run(mut args: Arguments) -> Result<()> {
    let config = Config::from_args(&mut args)?;
    let mut du = Du::new();
    du.run(&config)
}

dua:

pub fn run() -> Result {
    let opt = Opt::from_args();
    let mut app = App::new(opt.color.into(), opt.format)?;
    app.run()
}

Both projects use similar high-level structures for their main execution flow, initializing configuration from command-line arguments and then running the core functionality. The main difference lies in the naming conventions and specific implementation details.

dust focuses on providing a more visually rich output with additional sorting and viewing options, while dua-cli emphasizes performance and detailed file information. Users who prioritize aesthetics and flexible analysis might prefer dust, while those seeking raw speed and file-level details may lean towards dua-cli.

12,655

Disk Usage/Free Utility - a better 'df' alternative

Pros of duf

  • Colorful and visually appealing output with ASCII art graphs
  • Supports multiple devices and mount points in a single view
  • Includes additional information like file system type and mount flags

Cons of duf

  • May be slower for scanning large directories or file systems
  • Less focused on interactive exploration of disk usage by directory

Code Comparison

duf:

func (m *Mount) Usage() (*syscall.Statfs_t, error) {
    var stat syscall.Statfs_t
    err := syscall.Statfs(m.Mountpoint, &stat)
    return &stat, err
}

dua-cli:

pub fn walk_dir(
    root: &Path,
    opts: &WalkOptions,
) -> impl Iterator<Item = Result<EntryData>> {
    WalkDir::new(root).min_depth(1).into_iter().filter_map(move |e| {
        let e = e.ok()?;
        Some(Ok(EntryData::from_walk_entry(&e, opts)))
    })
}

The code snippets show different approaches:

  • duf focuses on retrieving file system information
  • dua-cli emphasizes directory traversal and file analysis

Both tools serve similar purposes but cater to different user preferences and use cases. duf provides a more visual and comprehensive overview, while dua-cli offers faster performance and interactive exploration capabilities.

33,285

A simple, fast and user-friendly alternative to 'find'

Pros of fd

  • Faster and more user-friendly alternative to the find command
  • Colorized output and smart case sensitivity by default
  • Supports regular expressions and glob patterns for flexible searching

Cons of fd

  • Limited to file and directory search, lacks disk usage analysis
  • May require additional tools for comprehensive file system management
  • Does not provide detailed information about file sizes or space consumption

Code Comparison

fd:

let regex = RegexBuilder::new(&pattern)
    .case_insensitive(true)
    .build()
    .unwrap();

dua:

let mut sizes = BTreeMap::new();
for entry in WalkDir::new(root).into_iter().filter_map(|e| e.ok()) {
    let size = entry.metadata()?.len();
    sizes.entry(entry.path().to_owned()).or_insert(size);
}

fd focuses on efficient file searching with regex support, while dua emphasizes disk usage analysis and size calculations. fd's code snippet demonstrates regex pattern building, whereas dua's code shows file traversal and size aggregation. Both projects utilize Rust for performance, but their core functionalities differ significantly.

47,483

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

Pros of ripgrep

  • Faster and more efficient for searching large codebases
  • Supports advanced regex patterns and search options
  • Automatically respects gitignore rules

Cons of ripgrep

  • Limited to text search functionality
  • Requires more complex command-line arguments for advanced features
  • Not designed for disk usage analysis

Code comparison

ripgrep:

pub fn search<R: io::Read>(reader: R) -> io::Result<()> {
    let mut grep = grep::Grep::new(&Config::default());
    grep.search(reader, |line| {
        println!("{}", line);
        Ok(true)
    })
}

dua-cli:

pub fn aggregate(path: &Path) -> io::Result<Aggregation> {
    let mut aggregator = Aggregator::new();
    for entry in WalkDir::new(path).into_iter().filter_map(|e| e.ok()) {
        aggregator.process_entry(&entry)?;
    }
    Ok(aggregator.finalize())
}

While both projects are written in Rust, ripgrep focuses on text searching functionality, whereas dua-cli is designed for disk usage analysis. The code snippets demonstrate their different purposes: ripgrep's search function and dua-cli's file system traversal and aggregation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Rust Crates.io Packaging status

dua (-> Disk Usage Analyzer) is a tool to conveniently learn about the usage of disk space of a given directory. It's parallel by default and will max out your SSD, providing relevant information as fast as possible. Optionally delete superfluous data, and do so more quickly than rm.

asciicast

Installation

Binary Release

MacOS

curl -LSfs https://raw.githubusercontent.com/Byron/dua-cli/master/ci/install.sh | \
    sh -s -- --git Byron/dua-cli --crate dua --tag v2.29.0

MacOS via MacPorts:

sudo port selfupdate
sudo port install dua-cli

MacOS via Homebrew

brew update
brew install dua-cli

Linux

Linux requires the target to be specified explicitly to obtain the MUSL build.

curl -LSfs https://raw.githubusercontent.com/Byron/dua-cli/master/ci/install.sh | \
    sh -s -- --git Byron/dua-cli --target x86_64-unknown-linux-musl --crate dua --tag v2.29.0

Windows via Scoop

scoop install dua

Pre-built Binaries

See the releases section for manual installation of a binary, pre-built for many platforms.

Cargo

Via cargo, which can be obtained using rustup

For _Unix_…

cargo install dua-cli

# And if you don't need a terminal user interface (most compatible)
cargo install dua-cli --no-default-features

# Compiles on most platforms, with terminal user interface
cargo install dua-cli --no-default-features --features tui-crossplatform

For Windows, nightly features are currently required.

cargo +nightly install dua-cli

VoidLinux

Via xbps on your VoidLinux system.

xbps-install dua-cli

Fedora

Via dnf on your Fedora system.

sudo dnf install dua-cli

Arch Linux

Via pacman on your ArchLinux system.

sudo pacman -S dua-cli

NixOS

https://search.nixos.org/packages?channel=23.11&show=dua&from=0&size=50&sort=relevance&type=packages&query=dua

Nix-shell (temporary)

nix-shell -p dua

NixOS configuration

  environment.systemPackages = [
    pkgs.dua
  ];

NetBSD

Via pkgin on your NetBSD system.

pkgin install dua-cli

Or, building from source

cd /usr/pkgsrc/sysutils/dua-cli
make install

Windows

You will find pre-built binaries for Windows in the releases section. Alternatively, install via cargo as in

cargo +nightly install dua-cli

x-cmd

x-cmd is a toolbox for Posix Shell, offering a lightweight package manager built using shell and awk.

x env use dua
  • Additionally, the x dua ... command is available, which automatically installs dua without affecting the environment, such as not modifying the PATH variable.

Usage

# count the space used in the current working directory
dua
# count the space used in all directories that are not hidden
dua *
# learn about additional functionality
dua aggregate --help

Interactive Mode

Launch into interactive mode with the i or interactive subcommand. Get help on keyboard shortcuts with ?. Use this mode to explore, and/or to delete files and directories to release disk space.

Please note that great care has been taken to prevent accidential deletions due to a multi-stage process, which makes this mode viable for exploration.

dua i
dua interactive

Development

Please note that all the following assumes a unix system. On Windows, the linux subsystem should do the job.

Run tests

make tests

Learn about other targets

make

But why is…

…there only one available backend? termion was available previously.

Maintaining both backends seemed more cumbersome than it's worth and add complexity I didn't like anymore. termion had its benefits, but I never liked that it seems to have dropped out of support. Thus crossterm is the only remaining backend and it's very actively developed.

Acknowledgements

Thanks to jwalk, all there was left to do is to write a command-line interface. As jwalk matures, dua should benefit instantly.

Limitations

  • Does not show symbolic links at all if no path is provided when invoking dua
    • in an effort to skip symbolic links, for now there are pruned and are not used as a root. Symbolic links will be shown if they are not a traversal root, but will not be followed.
  • Interactive mode only looks good in dark terminals (see this issue)
  • easy fix: file names in main window are not truncated if too large. They are cut off on the right.
  • There are plenty of examples in tests/fixtures which don't render correctly in interactive mode. This can be due to graphemes not interpreted correctly. With Chinese characters for instance, column sizes are not correctly computed, leading to certain columns not being shown. In other cases, the terminal gets things wrong - I use alacritty, and with certain characaters it performs worse than, say iTerm3. See https://github.com/minimaxir/big-list-of-naughty-strings/blob/master/blns.txt for the source.
  • In interactive mode, you will need about 60MB of memory for 1 million entries in the graph.
  • In interactive mode, the maximum amount of files is limited to 2^32 - 1 (u32::max_value() - 1) entries.
    • One node is used as to 'virtual' root
    • The actual amount of nodes stored might be lower, as there might be more edges than nodes, which are also limited by a u32 (I guess)
    • The limitation is imposed by the underlying petgraph crate, which declares it as unsafe to use u64 for instance.
    • It's possibly UB when that limit is reached, however, it was never observed either.

Similar Programs