summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Mike Burns <mike@mike-burns.com>2013-08-02 17:37:41 -0400
committerGravatar Mike Burns <mike@mike-burns.com>2013-08-03 12:32:48 -0400
commit22b4bd5555fb8c56aa3137c19ec24704ddc3f64f (patch)
tree7b53522ab86b3b1f30240cc60ea83f97fe8d982e
parent5ebd40d8ab1d4806924476a3853edb101ca0a6ff (diff)
Add rcdn
This program will remove all your rc files that are symlinked. This can be further controlled by `-d` and `-t`. For example, you can feel comfortable trying new rc files because you can quickly remove them again with `-d`. rcup -d thoughtbot-dotfiles rcdn -d thoughtbot-dotfiles Likewise, when you're done with Python just drop it: rcdn -t python
-rw-r--r--NEWS.md.in1
-rw-r--r--bin/Makefile.am2
-rw-r--r--bin/Makefile.in2
-rwxr-xr-xbin/rcdn53
-rw-r--r--man/Makefile.am2
-rw-r--r--man/Makefile.in2
-rw-r--r--man/lsrc.11
-rw-r--r--man/mkrc.11
-rw-r--r--man/rcdn.152
-rw-r--r--man/rcm.712
-rw-r--r--man/rcrc.51
-rw-r--r--man/rcup.11
-rw-r--r--share/rcm.sh.in3
13 files changed, 127 insertions, 6 deletions
diff --git a/NEWS.md.in b/NEWS.md.in
index 2061768..f24f2bd 100644
--- a/NEWS.md.in
+++ b/NEWS.md.in
@@ -2,6 +2,7 @@ rcm (@PACKAGE_VERSION@) unstable; urgency=low
* Improved Debian handling.
* Introduce mkrc -o to install host-specific dotfiles.
+ * Add rcdn(1) to remove rc files.
-- Mike Burns <mburns@thoughtbot.com> Tue, 01 Aug 2013 16:43:33 +0200
diff --git a/bin/Makefile.am b/bin/Makefile.am
index 351ea94..46ff33f 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -1 +1 @@
-bin_SCRIPTS = lsrc mkrc rcup
+bin_SCRIPTS = lsrc mkrc rcup rcdn
diff --git a/bin/Makefile.in b/bin/Makefile.in
index 5c3880f..42d9875 100644
--- a/bin/Makefile.in
+++ b/bin/Makefile.in
@@ -167,7 +167,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-bin_SCRIPTS = lsrc mkrc rcup
+bin_SCRIPTS = lsrc mkrc rcup rcdn
all: all-am
.SUFFIXES:
diff --git a/bin/rcdn b/bin/rcdn
new file mode 100755
index 0000000..8695c63
--- /dev/null
+++ b/bin/rcdn
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+: ${RCM_LIB:=`dirname $0`/../share/rcm}
+. $RCM_LIB/rcm.sh
+
+handle_command_line() {
+ local arg_tags=
+ local verbosity=0
+ local version=0
+ local dotfiles_dirs=
+ local files=
+
+ while getopts Vqvt:d: opt; do
+ case "$opt" in
+ t) arg_tags="$arg_tags $OPTARG" ;;
+ v) verbosity=$(($verbosity + 1));;
+ q) verbosity=$(($verbosity - 1));;
+ d) dotfiles_dirs="$dotfiles_dirs $OPTARG" ;;
+ V) version=1
+ esac
+ done
+ shift $(($OPTIND-1))
+
+ handle_common_flags rcup $version $verbosity
+
+ tags=${arg_tags:-$TAGS}
+ dotfiles_dirs=${dotfiles_dirs:-$DOTFILES_DIRS}
+ files=$@
+
+ for tag in $tags; do
+ LS_ARGS="$LS_ARGS -t $tag"
+ done
+ for dotfiles_dir in $dotfiles_dirs; do
+ LS_ARGS="$LS_ARGS -d $dotfiles_dir"
+ done
+ LS_ARGS="$LS_ARGS $files"
+
+ $DEBUG "LS_ARGS: $LS_ARGS"
+}
+
+if [ -e $HOME/.rcrc ]; then
+ . $HOME/.rcrc
+fi
+
+handle_command_line $*
+
+for dest_and_src in `lsrc $LS_ARGS`; do
+ dest=`echo $dest_and_src | sed 's/:.*//'`
+ src=`echo $dest_and_src | sed 's/.*://'`
+
+ $RM -rf $dest
+ rmdir -p `dirname $dest` 2>/dev/null
+done
diff --git a/man/Makefile.am b/man/Makefile.am
index 581184e..0674e27 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -1 +1 @@
-man_MANS = lsrc.1 mkrc.1 rcrc.5 rcup.1 rcm.7
+man_MANS = lsrc.1 mkrc.1 rcdn.1 rcup.1 rcrc.5 rcm.7
diff --git a/man/Makefile.in b/man/Makefile.in
index fecc814..51cc9de 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -171,7 +171,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-man_MANS = lsrc.1 mkrc.1 rcrc.5 rcup.1 rcm.7
+man_MANS = lsrc.1 mkrc.1 rcdn.1 rcup.1 rcrc.5 rcm.7
all: all-am
.SUFFIXES:
diff --git a/man/lsrc.1 b/man/lsrc.1
index b964115..ff67a1f 100644
--- a/man/lsrc.1
+++ b/man/lsrc.1
@@ -43,6 +43,7 @@ only list the specified file(s)
.Pa ~/.rcrc
.Sh SEE ALSO
.Xr mkrc 1 ,
+.Xr rcdn 1 ,
.Xr rcup 1 ,
.Xr rcrc 5 ,
.Xr rcm 7
diff --git a/man/mkrc.1 b/man/mkrc.1
index 69e2a04..05611d0 100644
--- a/man/mkrc.1
+++ b/man/mkrc.1
@@ -39,6 +39,7 @@ install dotfiles into the host-specific directory
.Dl mkrc -o ~/.rcrc
.Sh SEE ALSO
.Xr lsrc 1 ,
+.Xr rcdn 1 ,
.Xr rcup 1 ,
.Xr rcrc 5 ,
.Xr rcm 7
diff --git a/man/rcdn.1 b/man/rcdn.1
new file mode 100644
index 0000000..65c9bf0
--- /dev/null
+++ b/man/rcdn.1
@@ -0,0 +1,52 @@
+.Dd August 2, 2013
+.Dt RCDN 1
+.Os
+.Sh NAME
+.Nm rcdn
+.Nd remove dotfiles
+.Sh SYNOPSIS
+.Nm rcdn
+.Op Fl vq
+.Op Fl t Ar tag
+.Op Fl d Ar dir
+.Op Ar files ...
+.Sh DESCRIPTION
+This program will remove all the rc files that the
+.Xr rcm 7
+suite knows about. This can be further controlled with the
+.Fl t
+and
+.Fl d
+flags.
+.Bl -tag
+.It Fl v
+increase verbosity. This can be repeated for extra verbosity.
+.It Fl q
+decrease verbosity
+.It Fl t Ar TAG
+remove dotfiles according to
+.Ar TAG
+.It Fl d Ar DIR
+remove dotfiles from the
+.Ar DIR .
+This can be specified multiple times.
+.It Ar files
+only remove the specified file(s)
+.El
+.
+.Sh EXAMPLES
+.Dl rcdn -v
+.Dl rcdn zshrc
+.Dl rcdn -t python
+.Dl rcdn -d ~/corporate-dotfiles
+.Sh FILES
+.Pa ~/.dotfiles
+.Pa ~/.rcrc
+.Sh SEE ALSO
+.Xr lsrc 1 ,
+.Xr mkrc 1 ,
+.Xr rcup 1 ,
+.Xr rcrc 5 ,
+.Xr rcm 7
+.Sh AUTHORS
+.An "Mike Burns" Aq mike@mike-burns.com
diff --git a/man/rcm.7 b/man/rcm.7
index 05ebd90..69ea809 100644
--- a/man/rcm.7
+++ b/man/rcm.7
@@ -7,6 +7,7 @@
.Sh SYNOPSIS
.Nm lsrc
.Nm mkrc
+.Nm rcdn
.Nm rcup
.Sh DESCRIPTION
The rcm suite of tools is for managing dotfiles directories. This is a
@@ -91,10 +92,16 @@ A less common situation is for all the filenames in your dotfiles
directory to be prefixed with a period. These files are skipped by the
rcm suite, and thus would result in nothing happening. The only option
in this case is to rename all the files, for example by using a shell
-command like the following. Note that this will break any existing
-symlinks.
+command like the following.
.Pp
.Dl find ~/.dotfiles -name '.*' -exec echo mv {} `echo {} | sed 's/\.//'` \;
+.Pp
+Note that this will break any existing symlinks. Those can be safely
+removed using the
+.Xr rcdn 1
+command.
+.Pp
+.Dl rcdn -v
.Ss COMMON PROBLEM: DOTFILES DIRECTORY NOT IN Pa ~/.dotfiles
This all assumes that your dotfiles directory is
.Pa ~/.dotfiles .
@@ -222,6 +229,7 @@ dotfiles, too.
.Sh SEE ALSO
.Xr lsrc 1 ,
.Xr mkrc 1 ,
+.Xr rcdn 1 ,
.Xr rcup 1 ,
.Xr rcrc 5
.Sh AUTHORS
diff --git a/man/rcrc.5 b/man/rcrc.5
index fa51748..c66e718 100644
--- a/man/rcrc.5
+++ b/man/rcrc.5
@@ -44,6 +44,7 @@ canonical source. The default value is
.Sh SEE ALSO
.Xr lsrc 1 ,
.Xr mkrc 1 ,
+.Xr rcdn 1 ,
.Xr rcup 1 ,
.Xr rcm 7
.Sh AUTHORS
diff --git a/man/rcup.1 b/man/rcup.1
index b4feca4..e7315ae 100644
--- a/man/rcup.1
+++ b/man/rcup.1
@@ -114,6 +114,7 @@ or from
.Sh SEE ALSO
.Xr lsrc 1 ,
.Xr mkrc 1 ,
+.Xr rcdn 1 ,
.Xr rcrc 5 ,
.Xr rcm 7
.Sh AUTHORS
diff --git a/share/rcm.sh.in b/share/rcm.sh.in
index 3b8b87b..f25665b 100644
--- a/share/rcm.sh.in
+++ b/share/rcm.sh.in
@@ -51,18 +51,21 @@ handle_common_flags() {
VERBOSE=echo
PRINT=echo
MV="$MV -v"
+ RM="$RM -v"
INSTALL="$INSTALL -vv"
elif [ $verbosity -eq 1 ]; then
DEBUG=:
VERBOSE=echo
PRINT=echo
MV="$MV -v"
+ RM="$RM -v"
INSTALL="$INSTALL -v"
elif [ $verbosity -eq 0 ]; then
DEBUG=:
VERBOSE=:
PRINT=echo
MV="$MV -v"
+ RM="$RM -v"
else
DEBUG=:
VERBOSE=: