Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🗂️ Table of Contents

ℹ️ About

safe-remove (sm) is designed as a safer alternative to rm. Similar to the Recycle Bin on Windows, targeted files are moved to a Recycle folder (~/.recycle by default). Said files are kept — collision-safe, auto-renamed — until they age and become stale (30 days by default). Stale files are deleted through rm (with a SAFE_MODE prompt by default) each sm call.

The Recycle Bin is only cleaned during subsequent sm calls, if applicable. One can automate this process by including sm & (no arguments) in their .bashrc/.bash_profile or other terminal start-up files.

📑 Usage

Command Syntax Description
Interactive --interactive, -i Prompt the user before placing files into the recycle
Help --help, -h Prints help and usage text for safe-remove
Version --version, -v Displays the version number of the program

⚙️ Configuration

The options below are set inside the installed script itself. To edit them, open sm in your editor of choice:

sudo vim /usr/local/bin/sm
Option Variable Default Description
Recycle Location RECYCLE_DIR_PATH $HOME/.recycle Directory where removed files are stored. Must already exist and be writable.
Stale File Threshold STALE_THRESH_DAYS 30 Number of days before a file is considered stale. Must be a positive integer.
Safe Mode Toggle SAFE_MODE 1 Set to 1 to prompt for approval before deleting stale files, or 0 to delete silently.

📝 Installation

Linux

(cd /tmp && SM_URL=$(curl -fsSL https://api.github.com/repos/KevinTyrrell/safe-remove/releases/latest | grep "zipball_url" | awk '{ print $2 }' | sed 's/,$//' | sed 's/"//g') && curl -fsSL -o sm.zip "$SM_URL" && unzip -q sm.zip -d sm && sudo install -m 755 sm/*/sm.sh /usr/local/bin/sm && rm -rf sm.zip sm)

POSIX-compatible (Windows)

mkdir -p ~/bin && cd ~/bin

# Add ~/bin to your environmental variable PATH

LOCATION=$(curl -s https://api.github.com/repos/KevinTyrrell/safe-remove/releases/latest \
| grep "zipball_url" \
| awk '{ print $2 }' \
| sed 's/,$//'       \
| sed 's/"//g' )     \
; curl -L -o sm $LOCATION

chmod +x sm

📃 License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

[See: LICENSE] for more information.

Back to top

About

A safer alternative to 'rm' in Bash. Moves files to a recycle folder, purging stale contents on subsequent runs.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages