1

Introduction

The program nnn has a send-to-trash functionality, and it uses trash-cli. I would like to use nnn and trash-cli on macOS. Reading trash-cli's homepage, I see it uses ~/.local/share/Trash/, while macOS' Trash is ~/.Trash.

I was thinking, I could create a symlink pointing to macOS' Trash. To test this, here is what I ran:

% cd ~/.local/share
% ln -s ~/.Trash Trash
% ls ~/.Trash
% touch deleteme
% mv deleteme Trash
% ls ~/.Trash
deleteme

So, it seems like this method works.

Testing trash-cli

Indeed, when I installed trash-cli, the command works (with the slight drawback of using a different format):

[nix-shell:/tmp]$ touch deleteme2

[nix-shell:/tmp]$ trash deleteme2

[nix-shell:/tmp]$ tree ~/.Trash/
/Users/redacted/.Trash/
├── deleteme
├── files
│   └── deleteme2
└── info
    └── deleteme2.trashinfo

2 directories, 3 files

[nix-shell:/tmp]$ trash-list
2022-04-29 15:23:37 /private/tmp/deleteme2

However, when I tried running trash-empty, it showed that it would delete other directories:

[nix-shell:/tmp]$ trash-empty
Would empty the following trash directories:
    - /Users/redacted/.local/share/Trash
    - /.Trash-501
    - /System/Volumes/VM/.Trash-501
    - /System/Volumes/Preboot/.Trash-501
    - /System/Volumes/Update/.Trash-501
    - /System/Volumes/xarts/.Trash-501
    - /System/Volumes/iSCPreboot/.Trash-501
    - /System/Volumes/Hardware/.Trash-501
    - /System/Volumes/Data/.Trash-501
    - /nix/.Trash-501
    - /System/Volumes/Update/mnt1/.Trash-501
Proceed? (y/n) n

I believe these are all user trashes, as my user number is 501. However, it's still a bit worrying.

My question

Is it safe to symlink .Trash and use trash-cli as normal?

Edit 2022-04-30

I have clarified the context (nnn) in my introduction.

2 Answers 2

2

I can't comment on the safety or security of that app except to say that it looks more complicated than others I've seen - and the one I use. There is a thread here on this subject that may prove informative; esp. this answer.

I posted an answer to a related question with my opinion, and a suggestion that creating an alias to this script was a good solution. I can say that it still works well for me.

If you'd like to use trash as I do here's the steps:

  1. Review the code & the comments to determine your comfort level

  2. From your teminal:

    • open your editor, copy and paste the code into it, save the file as filename trash.
    • move the file to /usr/local/bin:
    sudo mv trash /usr/local/bin
    
    • make trash executable:
    sudo chmod a+rx /usr/local/bin/trash
    
    • test its function (this may be easier with an empty trash)
    touch testfile.txt
    # verify testfile.txt exists, and then: 
    trash testfile.txt
    
    • you may see this: enter image description here
      if so, click OK
  3. Your testfile.txt should now be gone from your pwd, and be in the Trash folder now.

  4. If you want to set up an alias, add a line like this to your ~/.zshrc file:

    # you can change 'rmv' to whatever works for you - even `rm`
    alias rmv=/usr/local/bin/trash
    
1
  • The code looks good, but I'm not sure if this solution works for my case. I would like to use a command that uses ~/.local/share/Trash/, because that is the location used by the trash commands supported by NNN, namely trash-cli and gio trash. I have updated my question to clarify. Apr 30 at 16:20
0

As per the other answer there are ways that are much less complex that trash-cli, that is no need to much around with odd directories, so in your terms it is safer. They also can mark the trashed item so that it can be Put Back in the Finder (that is moved back to where you trashed it from)

There is an executable - trash from https://github.com/ali-rantakari/trash

By default it does the trashing my moving the file to the macOs location ~/.Trash.

However call with a -F flag and it will use Finder to do the trashing (as in the other answer)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .