Coder Social home page Coder Social logo

guancheng-li / trash.sh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qqays/trash.sh

0.0 0.0 0.0 15 KB

A safer rm alternative that moves files and directories to a trash bin instead of permanently deleting them. Simplifies file recovery with easy installation and an option to empty the trash.

License: MIT License

Shell 100.00%

trash.sh's Introduction

中文

trash.sh

trash.sh is a script that serves as a safe alternative to rm, allowing for secure handling of files and directories by moving them to a trash bin instead of permanently deleting them.

If you use trash.sh as described below, rm essentially becomes mv. trash.sh handles moving items to the trash for you, so please be aware of this change!

Installation

  1. Download the trash.sh file to your user directory:
wget https://raw.githubusercontent.com/qqAys/trash.sh/main/trash.sh -O ~/trash.sh
  1. Add execute permissions:
chmod +x ~/trash.sh
  1. Add an alias (doesn't have to be rm) to your .bashrc or .zshrc:
echo 'alias rm="~/trash.sh"' >> ~/.bashrc
source ~/.bashrc

Usage

"Deleting" Files or Directories

To move files or directories to the trash, use the rm command as usual:

rm file1 file2 directory1

You will receive a confirmation prompt before "deletion."

Emptying the Trash

Emptying the trash involves calling /bin/rm with the -rf parameter to clear the ~/.trash folder. This action is irreversible.

To empty the trash, use the -c parameter:

rm -c

You will be prompted to confirm the emptying of the trash, and its contents will be displayed before deletion.

Trash Structure

Files you "delete" will be renamed with the current timestamp and moved (mv) to the ~/.trash folder. If you "delete" a directory, its contents will not be renamed. The structure of the trash looks like this:

$ tree .trash/

.trash/
├── test_dir_1-2024-06-18_09-10-12
│   └── test_file.txt
├── test_file_1.txt-2024-06-18_09-10-12
└── test_file_2.txt-2024-06-18_09-10-12

1 directory, 3 files

Note ⚠️

Using trash.sh does not guarantee that data or files will be securely "deleted." You should still back up important data to ensure its safety.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Please submit a pull request or open an issue to discuss your ideas.

trash.sh's People

Contributors

qqays avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.