mirror of
https://github.com/bootandy/dust.git
synced 2026-01-10 20:24:25 -08:00
Compare commits
1 Commits
config_col
...
bye_bye_di
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8be6b2d9cd |
5
.github/workflows/CICD.yml
vendored
5
.github/workflows/CICD.yml
vendored
@@ -126,11 +126,6 @@ jobs:
|
||||
target: x86_64-unknown-linux-musl,
|
||||
use-cross: use-cross,
|
||||
}
|
||||
- {
|
||||
os: deb-latest,
|
||||
target: x86_64-unknown-linux-musl,
|
||||
use-cross: use-cross,
|
||||
}
|
||||
- { os: macos-latest, target: x86_64-apple-darwin }
|
||||
- { os: windows-latest, target: i686-pc-windows-gnu }
|
||||
- { os: windows-latest, target: i686-pc-windows-msvc }
|
||||
|
||||
598
Cargo.lock
generated
598
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
14
Cargo.toml
14
Cargo.toml
@@ -27,11 +27,11 @@ lto = true
|
||||
strip = true
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
lscolors = "0.21"
|
||||
nu-ansi-term = "0.50"
|
||||
terminal_size = "0.4"
|
||||
unicode-width = "0.2"
|
||||
ansi_term = "0.12"
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
lscolors = "0.13"
|
||||
terminal_size = "0.2"
|
||||
unicode-width = "0.1"
|
||||
rayon = "1"
|
||||
thousands = "0.2"
|
||||
stfu8 = "0.2"
|
||||
@@ -39,8 +39,8 @@ regex = "1"
|
||||
config-file = "0.2"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
sysinfo = "0.37"
|
||||
ctrlc = "3"
|
||||
sysinfo = "0.27"
|
||||
ctrlc = "3.4"
|
||||
chrono = "0.4"
|
||||
|
||||
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
||||
|
||||
25
README.md
25
README.md
@@ -13,17 +13,6 @@ Because I want an easy way to see where my disk is being used.
|
||||
|
||||

|
||||
|
||||
Study the above picture.
|
||||
|
||||
* We see `target` has 1.8G
|
||||
* `target/debug` is the same size as `target` - so we know nearly all the disk usage of the 1.5G is in this folder
|
||||
* `target/debug/deps` this is 1.2G - Note the bar jumps down to 70% to indicate that most disk usage is here but not all.
|
||||
* `target/debug/deps/dust-e78c9f87a17f24f3` - This is the largest file in this folder, but it is only 46M - Note the bar jumps down to 3% to indicate the file is small.
|
||||
|
||||
From here we can conclude:
|
||||
* `target/debug/deps` takes the majority of the space in `target` and that `target/debug/deps` has a large number of relatively small files.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
#### Cargo <a href="https://repology.org/project/du-dust/versions"><img src="https://repology.org/badge/vertical-allrepos/du-dust.svg" alt="Packaging status" align="right"></a>
|
||||
@@ -80,8 +69,6 @@ Dust will list a slightly-less-than-the-terminal-height number of the biggest su
|
||||
|
||||
The different colors on the bars: These represent the combined tree hierarchy & disk usage. The shades of grey are used to indicate which parent folder a subfolder belongs to. For instance, look at the above screenshot. `.steam` is a folder taking 44% of the space. From the `.steam` bar is a light grey line that goes up. All these folders are inside `.steam` so if you delete `.steam` all that stuff will be gone too.
|
||||
|
||||
If you are new to the tool I recommend to try tweaking the `-n` parameter. `dust -n 10`, `dust -n 50`.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
@@ -138,14 +125,4 @@ reverse=true
|
||||
- [dirstat-rs](https://github.com/scullionw/dirstat-rs)
|
||||
- `du -d 1 -h | sort -h`
|
||||
|
||||
## Why to use Dust over the Alternatives
|
||||
|
||||
Dust simply Does The Right Thing when handling lots of small files & directories. Dust keeps the output simple by only showing large entries.
|
||||
|
||||
Tools like ncdu & baobab, give you a view of directory sizes but you have no idea where the largest files are. For example directory A could have a size larger than directory B, but in fact the largest file is in B and not A. Finding this out via these other tools is not trivial whereas Dust will show the large file clearly in the tree hierarchy
|
||||
|
||||
Dust will not count hard links multiple times (unless you want to `-s`).
|
||||
|
||||
Typing `dust -n 90` will show you your 90 largest entries. `-n` is not quite like `head -n` or `tail -n`, dust is intelligent and chooses the largest entries
|
||||
|
||||
|
||||
Note: Apparent-size is calculated slightly differently in dust to gdu. In dust each hard link is counted as using file_length space. In gdu only the first entry is counted.
|
||||
|
||||
@@ -20,8 +20,8 @@ _dust() {
|
||||
'-T+[Number of threads to use]:THREADS:_default' \
|
||||
'--threads=[Number of threads to use]:THREADS:_default' \
|
||||
'--config=[Specify a config file to use]:FILE:_files' \
|
||||
'-n+[Display the '\''n'\'' largest entries. (Default is terminal_height)]:NUMBER:_default' \
|
||||
'--number-of-lines=[Display the '\''n'\'' largest entries. (Default is terminal_height)]:NUMBER:_default' \
|
||||
'-n+[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER:_default' \
|
||||
'--number-of-lines=[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER:_default' \
|
||||
'*-X+[Exclude any file or directory with this path]:PATH:_files' \
|
||||
'*--ignore-directory=[Exclude any file or directory with this path]:PATH:_files' \
|
||||
'-I+[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:FILE:_files' \
|
||||
|
||||
@@ -26,8 +26,8 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
||||
[CompletionResult]::new('-T', '-T ', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
||||
[CompletionResult]::new('--threads', '--threads', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
||||
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'Specify a config file to use')
|
||||
[CompletionResult]::new('-n', '-n', [CompletionResultType]::ParameterName, 'Display the ''n'' largest entries. (Default is terminal_height)')
|
||||
[CompletionResult]::new('--number-of-lines', '--number-of-lines', [CompletionResultType]::ParameterName, 'Display the ''n'' largest entries. (Default is terminal_height)')
|
||||
[CompletionResult]::new('-n', '-n', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)')
|
||||
[CompletionResult]::new('--number-of-lines', '--number-of-lines', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)')
|
||||
[CompletionResult]::new('-X', '-X ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
||||
[CompletionResult]::new('--ignore-directory', '--ignore-directory', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
||||
[CompletionResult]::new('-I', '-I ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter')
|
||||
|
||||
@@ -23,8 +23,8 @@ set edit:completion:arg-completer[dust] = {|@words|
|
||||
cand -T 'Number of threads to use'
|
||||
cand --threads 'Number of threads to use'
|
||||
cand --config 'Specify a config file to use'
|
||||
cand -n 'Display the ''n'' largest entries. (Default is terminal_height)'
|
||||
cand --number-of-lines 'Display the ''n'' largest entries. (Default is terminal_height)'
|
||||
cand -n 'Number of lines of output to show. (Default is terminal_height - 10)'
|
||||
cand --number-of-lines 'Number of lines of output to show. (Default is terminal_height - 10)'
|
||||
cand -X 'Exclude any file or directory with this path'
|
||||
cand --ignore-directory 'Exclude any file or directory with this path'
|
||||
cand -I 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
complete -c dust -s d -l depth -d 'Depth to show' -r
|
||||
complete -c dust -s T -l threads -d 'Number of threads to use' -r
|
||||
complete -c dust -l config -d 'Specify a config file to use' -r -F
|
||||
complete -c dust -s n -l number-of-lines -d 'Display the \'n\' largest entries. (Default is terminal_height)' -r
|
||||
complete -c dust -s n -l number-of-lines -d 'Number of lines of output to show. (Default is terminal_height - 10)' -r
|
||||
complete -c dust -s X -l ignore-directory -d 'Exclude any file or directory with this path' -r -F
|
||||
complete -c dust -s I -l ignore-all-in-file -d 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter' -r -F
|
||||
complete -c dust -s z -l min-size -d 'Minimum size file to include in output' -r
|
||||
|
||||
@@ -28,6 +28,3 @@ ignore-hidden=true
|
||||
output-format="si"
|
||||
|
||||
number-of-lines=5
|
||||
|
||||
# To keep the .git directory collapsed
|
||||
collapse=[".git"]
|
||||
|
||||
@@ -19,7 +19,7 @@ Number of threads to use
|
||||
Specify a config file to use
|
||||
.TP
|
||||
\fB\-n\fR, \fB\-\-number\-of\-lines\fR \fI<NUMBER>\fR
|
||||
Display the \*(Aqn\*(Aq largest entries. (Default is terminal_height)
|
||||
Number of lines of output to show. (Default is terminal_height \- 10)
|
||||
.TP
|
||||
\fB\-p\fR, \fB\-\-full\-paths\fR
|
||||
Subdirectories will not have their path shortened
|
||||
|
||||
BIN
media/snap.png
BIN
media/snap.png
Binary file not shown.
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 61 KiB |
@@ -21,7 +21,7 @@ pub struct Cli {
|
||||
#[arg(long, value_name("FILE"), value_hint(ValueHint::FilePath))]
|
||||
pub config: Option<String>,
|
||||
|
||||
/// Display the 'n' largest entries. (Default is terminal_height)
|
||||
/// Number of lines of output to show. (Default is terminal_height - 10)
|
||||
#[arg(short, long, value_name("NUMBER"))]
|
||||
pub number_of_lines: Option<usize>,
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ pub struct Config {
|
||||
pub files0_from: Option<String>,
|
||||
pub number_of_lines: Option<usize>,
|
||||
pub files_from: Option<String>,
|
||||
pub collapse: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@@ -178,14 +177,6 @@ impl Config {
|
||||
pub fn get_changed_time_operator(&self, options: &Cli) -> Option<(Operator, i64)> {
|
||||
get_filter_time_operator(options.ctime.as_ref(), get_current_date_epoch_seconds())
|
||||
}
|
||||
|
||||
pub fn get_collapse(&self, options: &Cli) -> Option<Vec<String>> {
|
||||
if self.collapse.is_none() {
|
||||
options.collapse.clone()
|
||||
} else {
|
||||
self.collapse.clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_current_date_epoch_seconds() -> i64 {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::display_node::DisplayNode;
|
||||
use crate::node::FileTime;
|
||||
|
||||
use ansi_term::Colour::Red;
|
||||
use lscolors::{LsColors, Style};
|
||||
use nu_ansi_term::Color::Red;
|
||||
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
@@ -403,7 +403,7 @@ fn get_pretty_name(
|
||||
.ls_colors
|
||||
.style_for_path_with_metadata(&node.name, meta_result.as_ref().ok());
|
||||
let ansi_style = directory_color
|
||||
.map(Style::to_nu_ansi_term_style)
|
||||
.map(Style::to_ansi_term_style)
|
||||
.unwrap_or_default();
|
||||
let out = ansi_style.paint(name_and_padding);
|
||||
format!("{out}")
|
||||
|
||||
12
src/main.rs
12
src/main.rs
@@ -29,7 +29,7 @@ use std::panic;
|
||||
use std::process;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use sysinfo::System;
|
||||
use sysinfo::{System, SystemExt};
|
||||
use utils::canonicalize_absolute_path;
|
||||
|
||||
use self::display::draw_it;
|
||||
@@ -69,7 +69,7 @@ fn should_init_color(no_color: bool, force_color: bool) -> bool {
|
||||
{
|
||||
// Required for windows 10
|
||||
// Fails to resolve for windows 8 so disable color
|
||||
match nu_ansi_term::enable_ansi_support() {
|
||||
match ansi_term::enable_ansi_support() {
|
||||
Ok(_) => true,
|
||||
Err(_) => {
|
||||
eprintln!("This version of Windows does not support ANSI colors");
|
||||
@@ -224,7 +224,7 @@ fn main() {
|
||||
indicator.spawn(output_format.clone())
|
||||
}
|
||||
|
||||
let keep_collapsed: HashSet<PathBuf> = match config.get_collapse(&options) {
|
||||
let keep_collapsed: HashSet<PathBuf> = match options.collapse {
|
||||
Some(ref collapse) => {
|
||||
let mut combined_dirs = HashSet::new();
|
||||
for collapse_dir in collapse {
|
||||
@@ -440,10 +440,10 @@ fn init_rayon(stack: &Option<usize>, threads: &Option<usize>) -> rayon::ThreadPo
|
||||
None
|
||||
} else {
|
||||
let large_stack = usize::pow(1024, 3);
|
||||
let mut sys = System::new_all();
|
||||
sys.refresh_memory();
|
||||
let mut s = System::new();
|
||||
s.refresh_memory();
|
||||
// Larger stack size if possible to handle cases with lots of nested directories
|
||||
let available = sys.available_memory();
|
||||
let available = s.available_memory();
|
||||
if available > (large_stack * threads.unwrap_or(1)).try_into().unwrap() {
|
||||
Some(large_stack)
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use assert_cmd::{Command, cargo_bin_cmd};
|
||||
use assert_cmd::Command;
|
||||
use std::ffi::OsStr;
|
||||
use std::process::Output;
|
||||
use std::sync::Once;
|
||||
@@ -61,11 +61,9 @@ fn initialize() {
|
||||
|
||||
fn run_cmd<T: AsRef<OsStr>>(command_args: &[T]) -> Output {
|
||||
initialize();
|
||||
let mut to_run = cargo_bin_cmd!("dust");
|
||||
// Hide progress bar
|
||||
to_run.arg("-P");
|
||||
let mut to_run = &mut Command::cargo_bin("dust").unwrap();
|
||||
for p in command_args {
|
||||
to_run.arg(p);
|
||||
to_run = to_run.arg(p);
|
||||
}
|
||||
to_run.unwrap()
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use assert_cmd::cargo_bin_cmd;
|
||||
use assert_cmd::Command;
|
||||
use std::ffi::OsStr;
|
||||
use std::str;
|
||||
|
||||
@@ -9,16 +9,17 @@ use std::str;
|
||||
*/
|
||||
|
||||
fn build_command<T: AsRef<OsStr>>(command_args: Vec<T>) -> String {
|
||||
let mut cmd = cargo_bin_cmd!("dust");
|
||||
|
||||
let mut cmd = &mut Command::cargo_bin("dust").unwrap();
|
||||
// Hide progress bar
|
||||
cmd.arg("-P");
|
||||
cmd = cmd.arg("-P");
|
||||
|
||||
for p in command_args {
|
||||
cmd.arg(p);
|
||||
cmd = cmd.arg(p);
|
||||
}
|
||||
let finished = &cmd.unwrap();
|
||||
assert_eq!(str::from_utf8(&finished.stderr).unwrap(), "");
|
||||
let stderr = str::from_utf8(&finished.stderr).unwrap();
|
||||
assert_eq!(stderr, "");
|
||||
|
||||
str::from_utf8(&finished.stdout).unwrap().into()
|
||||
}
|
||||
|
||||
@@ -125,7 +126,7 @@ pub fn test_files0_from_flag_file() {
|
||||
|
||||
#[test]
|
||||
pub fn test_files_from_flag_stdin() {
|
||||
let mut cmd = cargo_bin_cmd!("dust");
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
cmd.arg("-P").arg("--files-from").arg("-");
|
||||
let input = b"tests/test_dir_files_from/a_file\ntests/test_dir_files_from/hello_file\n";
|
||||
cmd.write_stdin(input.as_ref());
|
||||
@@ -139,7 +140,7 @@ pub fn test_files_from_flag_stdin() {
|
||||
|
||||
#[test]
|
||||
pub fn test_files0_from_flag_stdin() {
|
||||
let mut cmd = cargo_bin_cmd!("dust");
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
cmd.arg("-P").arg("--files0-from").arg("-");
|
||||
let input = b"tests/test_dir_files_from/a_file\0tests/test_dir_files_from/hello_file\0";
|
||||
cmd.write_stdin(input.as_ref());
|
||||
@@ -153,7 +154,7 @@ pub fn test_files0_from_flag_stdin() {
|
||||
|
||||
#[test]
|
||||
pub fn test_with_bad_param() {
|
||||
let mut cmd = cargo_bin_cmd!("dust");
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
cmd.arg("-P").arg("bad_place");
|
||||
let output_error = cmd.unwrap_err();
|
||||
let result = output_error.as_output().unwrap();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use assert_cmd::{Command, cargo_bin_cmd};
|
||||
use assert_cmd::Command;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
@@ -44,7 +44,7 @@ pub fn test_soft_sym_link() {
|
||||
let b = format!(" ┌── {}", file_path_s);
|
||||
let a = format!("─┴ {}", dir_s);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("dust");
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
// Mac test runners create long filenames in tmp directories
|
||||
let output = cmd
|
||||
.args(["-p", "-c", "-s", "-w", "999", dir_s])
|
||||
@@ -72,7 +72,7 @@ pub fn test_hard_sym_link() {
|
||||
let file_output = format!(" ┌── {}", file_path_s);
|
||||
let dirs_output = format!("─┴ {}", dir_s);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("dust");
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
// Mac test runners create long filenames in tmp directories
|
||||
let output = cmd.args(["-p", "-c", "-w", "999", dir_s]).unwrap().stdout;
|
||||
|
||||
@@ -96,7 +96,7 @@ pub fn test_hard_sym_link_no_dup_multi_arg() {
|
||||
let link_name = dir_link.path().join("the_link");
|
||||
let link_name_s = link_it(link_name, file_path_s, false);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("dust");
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
|
||||
// Mac test runners create long filenames in tmp directories
|
||||
let output = cmd
|
||||
@@ -123,7 +123,7 @@ pub fn test_recursive_sym_link() {
|
||||
let a = format!("─┬ {}", dir_s);
|
||||
let b = format!(" └── {}", link_name_s);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("dust");
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd
|
||||
.arg("-p")
|
||||
.arg("-c")
|
||||
|
||||
Reference in New Issue
Block a user