andreafrancia / trash-cli

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

feature request: trash-restore accept argument instead of prompt and support specific destination to store #175

Open snowman opened 4 years ago

snowman commented 4 years ago

When running trash-restore without argument, which by default show restorable files in list, and prompt user to select one to restore

$ trash-restore
0 2020-09-28 09:29:57 /tmp/foo.sh
1 2020-09-28 09:49:22 /tmp/bar.sh
2 2020-09-28 09:49:31 /tmp/custom.el
What file to restore [0..2]:

I want to run without interaction, like when run trash-restore 0, it should output something like:

restore /tmp/foo.sh SUCCESS.
# but if output already exists, exit or prompt to confirm overwrite or force overwrite
$ touch /tmp/foo.sh
$ trash-restore 0
Refusing to overwrite existing file "foo.sh"
ignore me
or maybe specify DEST directory to restore the file,
like when specify both number and DEST,
it should move the whole path (create its parent directory if NOT exist), like:
```
$ trash-restore 0 /tmp
restore /tmp/foo.sh to /tmp/tmp/foo.sh SUCCESS
```
jeyj0 commented 3 years ago

It'd also be nice if trash-restore could accept lines from trash-ls. That would allow doing a simple pipe such as: trash-ls | fzf | trash-restore, which would be a very nice interface to use.

ItsProfessional commented 8 months ago

If someone is here from a google search on using trash-restore with fzf, I came up with a (hacky) solution:

alias trash-restore='echo 0 | trash-restore $(trash-list | grep $(pwd) --color=never | sed "s/^[^/]*//" | fzf) > /dev/null'

(Note: this will only list files in the current directory, if you want to list files everywhere remove the grep part)

andreafrancia commented 6 months ago

The number may change between different invocations. I think trash-restore should accept a path argument instead of a number.

ItsProfessional commented 6 months ago

I agree.