Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/lsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ lsd is a ls command with a lot of pretty colours and some other stuff to enrich
`-U`, `--no-sort`
: Do not sort. List entries in directory order

`-f`
: Do not sort and show hidden entries. Same as `-a -U`

`-Z` `--context`
: Display SELinux or SMACK security context

Expand Down
4 changes: 4 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ pub struct Cli {
#[arg(short = 'U', long, overrides_with_all = ["timesort", "sizesort", "extensionsort", "versionsort", "gitsort", "sort"])]
pub no_sort: bool,

/// Do not sort and show hidden entries. Same as -a -U
#[arg(short = 'f', overrides_with_all = ["timesort", "sizesort", "extensionsort", "versionsort", "gitsort", "sort"])]
pub no_sort_all: bool,

/// Reverse the order of the sort
#[arg(short, long)]
pub reverse: bool,
Expand Down
9 changes: 8 additions & 1 deletion src/flags/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Configurable<Self> for Display {
Some(Self::DirectoryOnly)
} else if cli.almost_all {
Some(Self::AlmostAll)
} else if cli.all {
} else if cli.all || cli.no_sort_all {
Some(Self::All)
} else if cli.system_protected {
#[cfg(windows)]
Expand Down Expand Up @@ -91,6 +91,13 @@ mod test {
assert_eq!(Some(Display::All), Display::from_cli(&cli));
}

#[test]
fn test_from_cli_no_sort_all() {
let argv = ["lsd", "-f"];
let cli = Cli::try_parse_from(argv).unwrap();
assert_eq!(Some(Display::All), Display::from_cli(&cli));
}

#[test]
fn test_from_cli_almost_all() {
let argv = ["lsd", "--almost-all"];
Expand Down
23 changes: 22 additions & 1 deletion src/flags/sorting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Configurable<Self> for SortColumn {
Some(Self::Version)
} else if cli.gitsort || sort == Some("git") {
Some(Self::GitStatus)
} else if cli.no_sort || sort == Some("none") {
} else if cli.no_sort || cli.no_sort_all || sort == Some("none") {
Some(Self::None)
} else {
None
Expand Down Expand Up @@ -236,6 +236,27 @@ mod test_sort_column {
assert_eq!(Some(SortColumn::None), SortColumn::from_cli(&cli));
}

#[test]
fn test_from_cli_no_sort_all() {
let argv = ["lsd", "-f"];
let cli = Cli::try_parse_from(argv).unwrap();
assert_eq!(Some(SortColumn::None), SortColumn::from_cli(&cli));
}

#[test]
fn test_from_cli_no_sort_all_overridden_by_later_sort_flag() {
let argv = ["lsd", "-f", "-t"];
let cli = Cli::try_parse_from(argv).unwrap();
assert_eq!(Some(SortColumn::Time), SortColumn::from_cli(&cli));
}

#[test]
fn test_from_cli_no_sort_all_overrides_earlier_sort_flag() {
let argv = ["lsd", "-t", "-f"];
let cli = Cli::try_parse_from(argv).unwrap();
assert_eq!(Some(SortColumn::None), SortColumn::from_cli(&cli));
}

#[test]
fn test_from_cli_sort() {
let argv = ["lsd", "--sort", "time"];
Expand Down
15 changes: 15 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,21 @@ fn test_show_folder_of_symlink_for_long_multi() {
.stdout(predicate::str::contains("link/:"));
}

#[test]
fn test_no_sort_all_shows_hidden_entries() {
let dir = tempdir();
dir.child(".hidden").touch().unwrap();
dir.child("visible").touch().unwrap();
cmd()
.arg("-f")
.arg("-1")
.arg("--ignore-config")
.arg(dir.path())
.assert()
.stdout(predicate::str::contains(".hidden"))
.stdout(predicate::str::contains("visible"));
}

#[test]
fn test_version_sort() {
let dir = tempdir();
Expand Down