Skip to content

feat: make -t sort by modification time (GNU ls compat)#4

Open
catlee wants to merge 1 commit intomainfrom
catlee/sort-time-flag
Open

feat: make -t sort by modification time (GNU ls compat)#4
catlee wants to merge 1 commit intomainfrom
catlee/sort-time-flag

Conversation

@catlee
Copy link
Copy Markdown

@catlee catlee commented Apr 16, 2026

Problem

wls -trl (a very common GNU ls idiom) fails because in eza, -t is short for --time which selects which timestamp column to display and requires a value (modified, changed, accessed, created). When combined flags like -trl are parsed, r gets interpreted as the value for -t, which is invalid.

This is a known pain point when eza is aliased to ls — the most common way people use it. Since wish aliases ls to wls for all World users, GNU ls muscle memory should work.

Solution

Repurpose -t to mean "sort by modification time" (matching GNU ls behavior), and remove the -t short form from --time. The --time long form still works for selecting which time column to display, and the existing short flags for specific time fields (-m modified, -u accessed, -U created) are unaffected.

Changes

  • Remove -t short form from the --time flag
  • Add new -t/--sort-time flag (no value required, sorts by modification time)
  • Error if both -t and --sort are given (conflicting sort options)
  • Update help text and tests

GNU ls compatibility

GNU ls Before (wls) After (wls)
ls -t ❌ error (needs value) ✅ sort by mod time
ls -trl ❌ error (r not a valid time field) ✅ long, reversed, sorted by mod time
--time=accessed -l ✅ works ✅ still works

Breaking change

-t modified / -tmod no longer works as a short form of --time modified. Use --time modified or the dedicated short flags (-m, -u, -U) instead. This is an eza-ism that doesn't match GNU ls behavior, and since wls is aliased to ls, matching GNU conventions is more important.

Previously -t was short for --time (which time field to display) and
required a value. This made common GNU ls idioms like 'ls -trl' fail.

Now -t/--sort-time sorts by modification time (newest first), matching
GNU ls behavior. The --time long form still works for selecting which
time column to display.

Changes:
- Remove -t short form from --time flag
- Add new -t/--sort-time flag (no value, sorts by modification time)
- Error if -t and --sort are both given
- Update help text and tests
@catlee catlee marked this pull request as ready for review April 16, 2026 00:29
@catlee catlee self-assigned this Apr 16, 2026
@catlee catlee requested a review from burke April 16, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant