blrm is a wrapper of
rm command with user-defined blacklist.
blrm is a wrapper of the
rm command and can replace
rm seamlessly. The
difference is that
blrm will look up a user-defined blacklist before deleting
a file, and skips the file from deletion if there is a match. This can prevent
accidental misdeletions and save important files.
Write a blacklist file containing string patterns, glob patterns or regex patterns. For example:
*.mp3 ~ ~/* ~/.* ~user ~user/* ~user/.*
Recommended blacklist file path is
Write a config file with the following content:
rm_bin = /bin/rm matcher = fnmatch blacklist_file = ~/.config/blrm/blacklist
Config file path should be one of:
system config file:
user config file:
If both system and user config files exist, only user config file will be used.
rmin the shell will run
It’s recommended to keep the alias in
To run the builtin
To install via
pip install blrm
To install from source, run:
python setup.py install --prefix=/usr
There are three matchers available:
- Match against string patterns.
- Match against glob patterns.
- Match against regex patterns.
Depending on the matcher being used, each line in the blacklist may be seen as a string pattern, a glob pattern or a regex pattern.
The matching process has the following steps:
Each pattern in the blacklist is subject to Tilde Expansion.
Each command-line argument is subject to Tilde Expansion and then converted to an absolute path string.
If the expanded pattern is an absolute path, then the path string will be matched from its beginning (e.g.
If the expanded pattern is not an absolute path, then the path string will be searched from any index (e.g.
The matcher implementation is summarized in the following table:
The source code is licensed under the [GNU General Public License v3.0][GPLv3].
Copyright (C) 2016 Cyker Way
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.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Make sure you know which matcher you are using.
Specify the patterns correctly in blacklist:
Take care of absolute and non-absolute patterns.
Take care of
~in patterns if
blrmis run as a different user (e.g. with
Please remember: This software is WITHOUT ANY WARRANTY. Use it at your own risk.