feat: make -t sort by modification time (GNU ls compat)#4
Open
feat: make -t sort by modification time (GNU ls compat)#4
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
wls -trl(a very common GNUlsidiom) fails because in eza,-tis short for--timewhich selects which timestamp column to display and requires a value (modified,changed,accessed,created). When combined flags like-trlare parsed,rgets 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. Sincewishaliaseslstowlsfor all World users, GNUlsmuscle memory should work.Solution
Repurpose
-tto mean "sort by modification time" (matching GNUlsbehavior), and remove the-tshort form from--time. The--timelong form still works for selecting which time column to display, and the existing short flags for specific time fields (-mmodified,-uaccessed,-Ucreated) are unaffected.Changes
-tshort form from the--timeflag-t/--sort-timeflag (no value required, sorts by modification time)-tand--sortare given (conflicting sort options)GNU ls compatibility
lsls -tls -trlrnot a valid time field)--time=accessed -lBreaking change
-t modified/-tmodno longer works as a short form of--time modified. Use--time modifiedor the dedicated short flags (-m,-u,-U) instead. This is an eza-ism that doesn't match GNUlsbehavior, and since wls is aliased tols, matching GNU conventions is more important.