From 3c6cbc343d19e221756be024ba8d5bf2632c38d7 Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Fri, 7 Jun 2013 10:49:17 +0200 Subject: Initial commit This adds mkrc and rcup, along with a Makefile to handle installation. `rcup` is for installing files from the `~/.dotfiles` repo. It allows for tagged files and host-specific files, and can install/update one-off files. `mkrc` is for moving a normal file into the dotfiles repo. --- bin/mkrc | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 bin/mkrc (limited to 'bin/mkrc') diff --git a/bin/mkrc b/bin/mkrc new file mode 100755 index 0000000..39714ec --- /dev/null +++ b/bin/mkrc @@ -0,0 +1,60 @@ +#!/bin/sh + +set -x + +DOTFILES=$HOME/.dotfiles +MV=mv +INSTALL=./install +ROOT_DIR=$HOME + + +destination() { + if [ $# -eq 1 ]; then + echo $DOTFILES/$1 + else + echo $DOTFILES/tag-$2/$1 + fi +} + +install_dotfile() { + prior_wd=`pwd` + cd $DOTFILES + $INSTALL -t ${2:--} $1 + cd $prior_wd +} + +if [ $# -eq 0 ]; then + echo "Usage: dotfiles-add [-t tag] filename ..." + exit 1 +fi + +tag= +verbosity=0 +while getopts vqt: opt; do + case "$opt" in + t) tag=$OPTARG;; + v) verbosity=$(($verbosity + 1));; + q) verbosity=$(($verbosity - 1));; + esac +done +shift $(($OPTIND-1)) + +if [ $verbosity -ge 2 ]; then + MV="$MV -v" + INSTALL="$INSTALL -vv" +elif [ $verbosity -eq 1 ]; then + MV="$MV -v" + INSTALL="$INSTALL -v" +elif [ $verbosity -eq 0 ]; then + MV="$MV -v" +else + INSTALL="$INSTALL -q" +fi + +files=$@ + +for file in $files; do + dotless=`echo $file | sed -e "s|$ROOT_DIR/||" | sed -e 's/^\.//'` + $MV $file `destination $dotless $tag` + install_dotfile $dotless $tag +done -- cgit v1.2.3