This is a little project of mine that I created to stop the fear you get from accidentally recursively deleting your directory, by creating something like a Windows recycle bin, where you move all your files which could then be deleted at a later time. It does this by using an alias it creates called bin to move your file into the recycle bin.
These instructions will get you a copy of the project up and running on your local machine. For usage, see how to use section.
- Clone the repository.
git clone https://github.com/RAvgCoder/Linux-UnixRecycleBin.git- In the directory, run the __create_bin.sh script.
./__create_bin.sh- Run this command on your terminal to finalize changes
source ~/.profile-
Run
bin -hto create the recycle bin on your home directory named __RECYCLE_BIN and show helpfull flags -
Finally, enjoy the joy of never having to accidentally delete your files again.
The bin alias can be used like the mv command, the only difference being that it does not take in a destination folder, as it always goes to the recycle bin.
bin folders file other_stufSome extra flags have been added to make it easier to use, these are the list of supported ones. Because the bin alias is built around the mv command, its flags are supported too.
| Flags | Description |
|---|---|
-h |
Brings up a help menu for only the bin command |
--help |
Brings up a help menu for both the bin and mv command |
-c |
Clears the recycle bin |
-cF |
Clears the recycle bin for files that require a force removal equivalent to rm -rf |
-s |
Shows the content of the recycle bin |
To clear the bin
bin -cTo get help for only bin
bin -hTo show the contents of the recycle bin
bin -c- This program creates files on your computer in order to function properly, which may configuration files, and other data necessary for the program's operation. Please be aware of this before installing the program. The directories created are
- A
.profileand or.bashrcfile if it is not alredy on your machine. This helps the alias run when the machine is booted - A
.bash_aliasesfile if not already present which would store the alias comand it self you can change the mapping from here - The
.__aliaseSymbolsdirecory created in the home directory to store all necesary scipts needed to run the alias - A
man_Recycle_bin.shand analias_Recycle_bin.shwhich contain the manual for the command and the scipt for the command respectively. This is located in the.__aliaseSymbolsdirecory, created above.
- Due to Unix's unique methods of handling files, putting anything in the
__RECYCLE_BINthat already exists wouldn't be possible. So, I append the time format ofYYYY-MM-DD_HH:MM:SSto the file being deleted to allow for the deletion of files. For example given an empty bin, after deleting a folder called one, the content of our bin would give.
oneIf we delete two more with the same name it gives us
one
one-2023-04-29_21:15:02
one-2023-04-29_21:19:21This property can be changed in the ~/.__aliaseSymbols/alias_Recycle_bin.sh file