Updated doc and cleaned up some edge cases.
This commit is contained in:
parent
8b8f9cbf25
commit
db5da5b2a0
8
trash
8
trash
@ -47,8 +47,8 @@ Options:
|
|||||||
-r, -R, --recursive ignored (for compatability with rm)
|
-r, -R, --recursive ignored (for compatability with rm)
|
||||||
-u, --untrash restore file(s) from the trash
|
-u, --untrash restore file(s) from the trash
|
||||||
-e, --empty choose files to empty from the trash
|
-e, --empty choose files to empty from the trash
|
||||||
-E, --empty-all empty all the files in the trash
|
-E, --empty-all empty all the files in the trash folder(s) (default: ~)
|
||||||
-l, --list list files in the trash
|
-l, --list list files in trash folder(s) (default: ~)
|
||||||
-- Any arguments after '--' will be treated as filenames
|
-- Any arguments after '--' will be treated as filenames
|
||||||
EOU
|
EOU
|
||||||
}
|
}
|
||||||
@ -205,6 +205,7 @@ trash_file() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
untrash_files() {
|
untrash_files() {
|
||||||
|
[ $# -eq 0 ] && fail "No files provided to untrash"
|
||||||
for target; do
|
for target; do
|
||||||
if ! file="$(find_trashfile "$target")"; then
|
if ! file="$(find_trashfile "$target")"; then
|
||||||
[ "$force_flag" = "-f" ] || fail "No such file: $target"
|
[ "$force_flag" = "-f" ] || fail "No such file: $target"
|
||||||
@ -217,6 +218,7 @@ untrash_files() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
empty_files() {
|
empty_files() {
|
||||||
|
[ $# -eq 0 ] && fail "No files provided to empty"
|
||||||
for target; do
|
for target; do
|
||||||
if ! file="$(find_trashfile "$target")"; then
|
if ! file="$(find_trashfile "$target")"; then
|
||||||
[ "$force_flag" = "-f" ] || fail "No such file: $target"
|
[ "$force_flag" = "-f" ] || fail "No such file: $target"
|
||||||
@ -232,7 +234,7 @@ empty_trash() {
|
|||||||
[ $# -eq 0 ] && set "$PWD"
|
[ $# -eq 0 ] && set "$PWD"
|
||||||
for target; do
|
for target; do
|
||||||
td="$(get_trashdir "$(readlink -f -- "$target")")"
|
td="$(get_trashdir "$(readlink -f -- "$target")")"
|
||||||
[ -d "$td/files" ] || continue
|
[ -d "$td/files" ] && [ -n "$(ls -A "$td/files")" ] || continue
|
||||||
[ "$force_flag" != "-f" ] &&
|
[ "$force_flag" != "-f" ] &&
|
||||||
( printf '\033[1mThe following %s of files will be deleted:\033[0m\n' \
|
( printf '\033[1mThe following %s of files will be deleted:\033[0m\n' \
|
||||||
"$(du -h --summarize "$td/files" | cut -f1)B" &&
|
"$(du -h --summarize "$td/files" | cut -f1)B" &&
|
||||||
|
42
trash.1
42
trash.1
@ -11,11 +11,16 @@ trash \- A shell program for FreeDesktop.org-compliant trash management.
|
|||||||
[\fI-i\fR|\fI--interactive\fR]
|
[\fI-i\fR|\fI--interactive\fR]
|
||||||
[\fI-f\fR|\fI--force\fR]
|
[\fI-f\fR|\fI--force\fR]
|
||||||
[\fI-r\fR|\fI-R\fR|\fI--recursive\fR]
|
[\fI-r\fR|\fI-R\fR|\fI--recursive\fR]
|
||||||
|
[
|
||||||
[\fI-u\fR|\fI--untrash\fR]
|
[\fI-u\fR|\fI--untrash\fR]
|
||||||
|
|
|
||||||
[\fI-e\fR|\fI--empty\fR]
|
[\fI-e\fR|\fI--empty\fR]
|
||||||
|
|
|
||||||
[\fI-E\fR|\fI--empty-all\fR]
|
[\fI-E\fR|\fI--empty-all\fR]
|
||||||
|
|
|
||||||
[\fI-l\fR|\fI--list\fR]
|
[\fI-l\fR|\fI--list\fR]
|
||||||
[[\fI--\fR] [\fIfiles...\fR]]
|
]
|
||||||
|
[[\fI--\fR] \fIfiles...\fR]
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBtrash\fR is a small shell program that helps you send files to a trash
|
\fBtrash\fR is a small shell program that helps you send files to a trash
|
||||||
@ -49,25 +54,36 @@ Ignored. (For compatibility with \fBrm -r\fR)
|
|||||||
|
|
||||||
.B \-u
|
.B \-u
|
||||||
.B \--untrash
|
.B \--untrash
|
||||||
Bring up a fuzzy picker for restoring a file from the trash.
|
Restore the most recently deleted file(s) matching the given path(s). (see:
|
||||||
|
\fBNOTE ON DELETION TIMES\fR)
|
||||||
|
|
||||||
.B \-e
|
.B \-e
|
||||||
.B \--empty
|
.B \--empty
|
||||||
Empty one or more files from the trash.
|
Permanently erase the most recently deleted file(s) matching the given path(s)
|
||||||
|
from the trash. (see: \fBNOTE ON DELETION TIMES\fR)
|
||||||
|
|
||||||
.B \-E
|
.B \-E
|
||||||
.B \--empty-all
|
.B \--empty-all
|
||||||
Empty all files from the trash.
|
Empty all files from the trash. Since there is a per-mount-point trash directory,
|
||||||
|
any additional path arguments will be used to empty trash from specified mount
|
||||||
|
points. Default is the current directory.
|
||||||
|
|
||||||
.B \-l
|
.B \-l
|
||||||
.B \--list
|
.B \--list
|
||||||
List all files in the trash. The format is: \fB<Trash File>\fR, \fB<Date
|
List all files in the trash. The format is: \fB<Trash File>\fR, \fB<Date
|
||||||
Deleted>\fR, \fB<Original Path>\fR. Fields are separated by the environment
|
Deleted>\fR, \fB<Original Path>\fR. Fields are separated by the environment
|
||||||
variable \fIFS\fR (default: tab) and records are separated by the environment
|
variable \fIFS\fR (default: tab) and records are separated by the environment
|
||||||
variable \fIRS\fR (default: newline).
|
variable \fIRS\fR (default: newline). Since there is a per-mount-point trash
|
||||||
|
directory, any additional path arguments will be used to empty trash from
|
||||||
|
specified mount points. Default is the current directory.
|
||||||
|
|
||||||
.I files...
|
.I files...
|
||||||
The files to send to the trash.
|
If none of \fB-u\fR, \fB-e\fR, \fB-E\fR, \fB-l\fR are specified, then delete
|
||||||
|
the given files. Otherwise, apply the appropriate action to them.
|
||||||
|
|
||||||
|
.SH NOTE ON DELETION TIMES
|
||||||
|
\fBtrash\fR only records the deltion time with 1-second precision, so if
|
||||||
|
multiple files were deleted in the same second, the behavior is undefined.
|
||||||
|
|
||||||
.SH EXAMPLES
|
.SH EXAMPLES
|
||||||
.TP
|
.TP
|
||||||
@ -77,13 +93,23 @@ Send \fIfoo.txt\fR and \fIbaz.txt\fR to the trash.
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
trash -u
|
trash foo.txt && trash -u foo.txt
|
||||||
Pick a file and untrash it.
|
Trash a file and then untrash it.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
trash -E
|
trash -E
|
||||||
Empty the trash.
|
Empty the trash.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
trash -E /mnt
|
||||||
|
Empty the trash on the filesystem mounted at /mnt
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
trash -E $(awk '{print $2}' /proc/mounts)
|
||||||
|
Empty all trash directories on all filesystems on the system.
|
||||||
|
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
Bruce Hill (bruce@bruce-hill.com)
|
Bruce Hill (bruce@bruce-hill.com)
|
||||||
|
Loading…
Reference in New Issue
Block a user