andreafrancia / trash-cli

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

Provide an option to send deleted items to macOS Desktop Trash. #323

Closed slferris closed 7 months ago

slferris commented 7 months ago

Is your feature request related to a problem? Please describe.

I am using NNN on macOS Sonoma with zsh and Oh-My-Zsh.

When I invoke export NNN_TRASH=1 to use trash-cli to export deleted files, trash-cli puts the deleted files in ~/.local/share/Trash/files. I want them sent to my Desktop Trash at ~/.Trash. I don't want to have to look for trashed files in two places. I have placed export NNN_TRASH_CUSTOM="$HOME/.Trash" in my .zshrc config file, but trash-cli still ignores it and sends deleted files to ~/.local/share/Trash/files. I have also created a symlink from the latter to ~/.Trash, but it doesn't quite work the way I would like.

How can I get trash-cli to put files deleted in NNN into my Desktop Trash, just like any other files I trash?

Describe the solution you'd like

An option to put deleted items to Desktop Trash when using NNN.

Describe alternatives you've considered

A symlink between ~/.local/share/Trash/files

Additional context Add any other context or screenshots about the feature request here.

andreafrancia commented 7 months ago

trash-cli implements the The FreeDesktop.org Trash specification, but macOS does not. trash-cli will not include support for macOS trash. On macOS you can try this program: https://hasseg.org/trash/

slferris commented 7 months ago

Andrea, thank you very much. Yours is the first really helpful response I’ve received regarding this issue.

Homebrew won’t install trash when trash-cli is present. I guess it’s OK to first delete trash-cli.

Also, I noticed that brew has another binary called macos-trash. Any idea if that might be even a better solution than trash?

Thanks again for your help. Steve

On Dec 9, 2023, at 2:32 AM, Andrea Francia @.***> wrote:

trash-cli implements the The FreeDesktop.org Trash specification, but macOS does not. trash-cli will not include support for macOS trash. On macOS you can try this program: https://hasseg.org/trash/

— Reply to this email directly, view it on GitHub https://github.com/andreafrancia/trash-cli/issues/323#issuecomment-1848345186, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJRHVVKWJH6HMG5PE4FB763YIQV2TAVCNFSM6AAAAABALPIK6KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBYGM2DKMJYGY. You are receiving this because you authored the thread.

andreafrancia commented 7 months ago

I've tried many command line trash clients for macOS, but the one from Ali Rantakari (http://hasseg.org/trash) is the only one that support the Put Back feature (but you need to use the -F option as described in the official github page (https://github.com/ali-rantakari/trash)

You can install both trash-cli and trash using this sequence of commands:

brew install trash
brew unlink trash
brew install trash-cli

Then you can define:

alias trash='/opt/homebrew/Cellar/trash/0.9.2/bin/trash -F'

Another option to avoid conflicts is to install trash-cli from pip (or pipx) and installing Ali Rantakari trash from brew.

slferris commented 7 months ago

Thanks, again. Am I correct in assuming that trash does not integrate with nnn? To use it, don't you have to leave nnn and invoke it in zsh?

andreafrancia commented 7 months ago

According to this line in the nnn:

static char * const utils[] = {
...
    "trash-put",
...
};

I think that Ali Rantakari trash is not supported. You can try to download the sources, change that line to "/opt/homebrew/Cellar/trash/0.9.2/bin/trash -F" and compile it.

N-R-K commented 6 months ago

@andreafrancia Thanks for taking the time to answer nnn related question on your repo.

I think that Ali Rantakari trash is not supported.

Yup, none of the active nnn maintainers use macos. So most macos features/fixes are just contributed by other users. Same goes for adding trash support on macos, if someone sends a functional PR, we'll likely accept it.

change that line to "/opt/homebrew/Cellar/trash/0.9.2/bin/trash -F"

Though we obviously can't have hard-coded path like this :)