andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.63k stars 177 forks source link

trash-restore should be ordered by date #168

Closed PHLAK closed 3 years ago

PHLAK commented 4 years ago

When running trash-restore in a directory with trashed files the files aren't sorted by time/date. It would be convenient for them to be sorted by deleted time/date so the most recently deleted file is at the bottom. This would make it easier to restore recently deleted files which are the files I'm most likely trying to restore.

Current Result

$ trash-restore
   0 2020-04-27 09:50:27 /tmp/file2
   1 2020-04-28 13:44:39 /tmp/file1
   2 2020-04-27 09:55:45 /tmp/file6
   3 2020-04-27 09:51:03 /tmp/file3
   4 2020-05-11 08:57:22 /tmp/file5
   5 2020-04-27 09:33:22 /tmp/file4
   6 2020-04-28 13:44:39 /tmp/file7

Expected Result

$ trash-restore
   0 2020-04-27 09:33:22 /tmp/file4
   1 2020-04-27 09:50:27 /tmp/file2
   2 2020-04-27 09:51:03 /tmp/file3
   3 2020-04-27 09:55:45 /tmp/file6
   4 2020-04-28 13:44:39 /tmp/file1
   5 2020-04-28 13:44:39 /tmp/file7
   6 2020-05-11 08:57:22 /tmp/file5

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:    20.04
Codename:   focal

$ trash --version
trash 0.17.1.14
Hund commented 4 years ago

You could always sort them yourself with trash-list | sort.

PHLAK commented 4 years ago

@Hund Of course that's possible (and what I do for now), however the current defaults could use improving.

nsirolli commented 3 years ago

You could always sort them yourself with trash-list | sort.

Does it help? It sorts the list of trashed files, but when running trash-restore you have to pass the number of the file that you want to restore, and you can't obtain easily that number by running trash-list | sort.

andreafrancia commented 3 years ago

trash-restore since version 0.20.11.7 accept --sort=date as parameter, this was implemented by @Self-Perfection in https://github.com/andreafrancia/trash-cli/pull/135

PHLAK commented 3 years ago

That's great @andreafrancia! Any reason why is this not the default though?

Self-Perfection commented 3 years ago

The reason is that my PR sorts by path by default.

PHLAK commented 3 years ago

I understand that @Self-Perfection. I'm making the argument that sorting by date would be better as the default since I predict when most users run trash-restore they are attempting to restore files that were deleted recently.

Self-Perfection commented 3 years ago

@PHLAK this makes sense. I'd suggest you create small PR for your suggestion.

PHLAK commented 3 years ago

Done @Self-Perfection. #179