Skip to content

Commit

Permalink
README.md: adds more instructions for configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Dec 11, 2024
1 parent a0cd3c3 commit bf2c9ee
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,22 @@ sudo sh uninstall.sh

## Configuration

Since 2.0.0, you could create a configuration file named `.safe-rm.conf` in your HOME directory, to support
Since 2.0.0, you could create a configuration file named `.safe-rm.conf` in your `$HOME` directory, to support
- defining your custom trash directory
- allowing `safe-rm` to permanently delete files and directories that are already in the trash
- disallowing `safe-rm` to use [AppleScript][applescript]

For the description of each config, you could refer to the sample file [here](./sample.safe-rm.conf)

```sh
# You could
cp ./sample.safe-rm.conf ~/.safe-rm.conf
```

If you want to use a custom configuration file

```sh
alias="SAFE_RM_CONF=/path/to/safe-rm.conf /path/to/bin/rm.sh"
alias="SAFE_RM_CONF=/path/to/safe-rm.conf /path/to/shell-safe-rm/bin/rm.sh"
```

Or if it is installed by npm:
Expand All @@ -134,6 +139,26 @@ Or if it is installed by npm:
alias="SAFE_RM_CONF=/path/to/safe-rm.conf safe-rm"
```

### Disable `Put-back` Functionality on MacOS (MacOS only)

In `~/.safe-rm.conf`

```sh
export SAFE_RM_USE_APPLESCRIPT=no
```

### Change the Default Trach Bin Other Than System Default

```sh
export SAFE_RM_TRASH=/path/to/trash
```

### Permanent Delete Files or Directories that Are Already in the Trash

```sh
export SAFE_RM_PERM_DEL_FILES_IN_TRASH=yes
```


[applescript]: https://en.wikipedia.org/wiki/AppleScript
[rm]: https://en.wikipedia.org/wiki/Rm_(Unix)
Expand Down
26 changes: 15 additions & 11 deletions sample.safe-rm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,39 @@

#
# If you want to use a trash directory other than the default system trash,
# uncomment the line after divider `-----*`
# uncomment the line after divider `-----`
# and set the path to the desired trash directory.
# By default, safe-rm will use the system trash.
# -----------------------------------------------
# export SAFE_RM_TRASH=/path/to/trash

#
# If you want to permanently delete files that are already in the trash,
# uncomment the line after divider `-----*`
# uncomment the line after divider `-----`
# It defaults to 'no'.
# Pay attention that any value that starts with 'y' or 'Y' will be treated as 'yes'.
# -----------------------------------------------
# export SAFE_RM_PERM_DEL_FILES_IN_TRASH=yes

#
# If you want to disable the use of AppleScript for moving files to the trash,
# uncomment the line after divider `-----*`
# uncomment the line after divider `-----`
# It defaults to 'yes'.
# By setting it to 'no', the "put-back" feature will be disabled for MacOS.
# -----------------------------------------------
# export SAFE_RM_USE_APPLESCRIPT=no

#
# The following directories or files will be protected and cannot be removed.
# If you want to protect some files or directories from being removed by
# safe-rm:
# - Uncomment the line after divider `-----`
# - Create a file at the path specified by SAFE_RM_PROTECTED_RULES, such as
# `~/.safe-rm.protected`
# - Add the rules to the file, one rule per line, the rule follows the # .gitingore syntax (https://git-scm.com/docs/gitignore). If a file or
# directory ignores by the rules, it will not be removed by safe-rm.
# ATTENTION that
# - Before enabling this feature, `git` must be installed.
# - It is unnecessary to put `/` in the protected rules. And you also should
# NOT do so, or all files will be protected.
# -----------------------------------------------
# export SAFE_RM_PROTECTED_TARGETS=/path/to/protected1:/path/to/protected2


# Everything inside the following directories, excluding those directories,
# will be protected and cannot be removed.
# -----------------------------------------------
# export SAFE_RM_PROTECTED_DIRECTORIES=/path/to/dir1:/path/to/dir2
# export SAFE_RM_PROTECTED_RULES="$HOME/.safe-rm.protected"

0 comments on commit bf2c9ee

Please sign in to comment.