summaryrefslogtreecommitdiff
path: root/bin
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 /bin
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
Diffstat (limited to 'bin')
-rw-r--r--bin/Makefile.am2
-rw-r--r--bin/Makefile.in2
-rwxr-xr-xbin/rcdn53
3 files changed, 55 insertions, 2 deletions
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