rn: Search for .rm dir in (grand*)parent dir.
This commit is contained in:
parent
2194675dda
commit
3b9100e574
6
Makefile
6
Makefile
|
@ -1,6 +1,8 @@
|
|||
CMD = blink bsearch G gitundo histogram upsidedown tracefile timestamp rand rclean rrm goodpasswd gitnext pdfman puniq ramusage ramusage
|
||||
CMD = blink bsearch G gitnext goodpasswd histogram neno \
|
||||
pdfman puniq ramusage rand rclean rn rrm timestamp tracefile \
|
||||
upsidedown wssh
|
||||
|
||||
all: blink/blink.1 bsearch/bsearch.1 G/G.1 gitnext/gitnext.1 gitundo/gitundo.1 goodpasswd/goodpasswd.1 histogram/histogram.1 neno/neno.1 pdfman/pdfman.1 puniq/puniq.1 rand/rand.1 rrm/rrm.1 timestamp/timestamp.1 tracefile/tracefile.1 upsidedown/upsidedown.1 wssh/wssh.1
|
||||
all: blink/blink.1 bsearch/bsearch.1 G/G.1 gitnext/gitnext.1 goodpasswd/goodpasswd.1 histogram/histogram.1 neno/neno.1 pdfman/pdfman.1 puniq/puniq.1 rand/rand.1 rn/rn.1 rrm/rrm.1 timestamp/timestamp.1 tracefile/tracefile.1 upsidedown/upsidedown.1 wssh/wssh.1
|
||||
|
||||
%.1: %
|
||||
pod2man $< > $@
|
||||
|
|
|
@ -20,6 +20,8 @@ is then displayed using $PDFVIEWER.
|
|||
|
||||
If $PDFVIEWER is unset, it tries B<okular>, B<evince>, and B<gv>.
|
||||
|
||||
If a viewer of the page is already running, a new viewer will not be
|
||||
started.
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
|
|
82
rn/rn
82
rn/rn
|
@ -1,19 +1,71 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir ~/.rm 2>/dev/null
|
||||
if mv "$@" ~/.rm ; then
|
||||
# OK
|
||||
true
|
||||
: <<=cut
|
||||
=encoding utf8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
rn - move file into wastebasket
|
||||
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<rn> I<file(s)>
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<rn> move files to a wastebasket dir called B<.rm>. It is created in
|
||||
$HOME directory if it cannot be found in any of the (grand*)parent
|
||||
directories.
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2017 Ole Tange,
|
||||
http://ole.tange.dk and Free Software Foundation, Inc.
|
||||
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
||||
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/>.
|
||||
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
B<mv>(1), B<rm>(1)
|
||||
|
||||
|
||||
=cut
|
||||
|
||||
find_rm_dir() {
|
||||
dir="$1"
|
||||
if [ -d "$1"/.rm ] ; then
|
||||
echo "$1"/.rm
|
||||
return 0
|
||||
else
|
||||
mkdir -p ~/.rm/{1..10}
|
||||
mv "$@" ~/.rm/1 2>/dev/null ||
|
||||
mv "$@" ~/.rm/2 2>/dev/null ||
|
||||
mv "$@" ~/.rm/3 2>/dev/null ||
|
||||
mv "$@" ~/.rm/4 2>/dev/null ||
|
||||
mv "$@" ~/.rm/5 2>/dev/null ||
|
||||
mv "$@" ~/.rm/6 2>/dev/null ||
|
||||
mv "$@" ~/.rm/7 2>/dev/null ||
|
||||
mv "$@" ~/.rm/8 2>/dev/null ||
|
||||
mv "$@" ~/.rm/9 2>/dev/null ||
|
||||
mv "$@" ~/.rm/10
|
||||
if [ "/" == $(readlink -f "$dir") ]; then
|
||||
echo $HOME/.rm
|
||||
return 0
|
||||
fi
|
||||
find_rm_dir "../$dir"
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
rmdir="$(find_rm_dir .)"
|
||||
mkdir -p "$rmdir"
|
||||
mv --backup=numbered "$@" $rmdir
|
||||
|
|
Loading…
Reference in a new issue