#!/bin/sh : ${RCM_LIB:=`dirname $0`/../share/rcm} . $RCM_LIB/rcm.sh destination() { local dotfiles_dir=$1 local dotless=$2 local in_host=$3 local tag=$4 if [ "x$tag" != "x" ]; then echo $dotfiles_dir/tag-$tag elif [ $in_host = 1 ]; then echo $dotfiles_dir/host-$HOSTNAME else echo $dotfiles_dir fi } if [ -e $HOME/.rcrc ]; then . $HOME/.rcrc fi if [ $# -eq 0 ]; then echo "Usage: mkrc [-vqo] [-t tag] [-d dir] files ..." exit 1 fi for DOTFILES_DIR in $DOTFILES_DIRS $DEFAULT_DOTFILES_DIR; do break done tag= verbosity=0 in_host=0 version=0 always_copy=0 while getopts CVvqot:d: opt; do case "$opt" in C) always_copy=1 ;; t) tag=$OPTARG ;; v) verbosity=$(($verbosity + 1)) ;; q) verbosity=$(($verbosity - 1)) ;; o) in_host=1 ;; d) DOTFILES_DIR=$OPTARG ;; V) version=1 ;; esac done shift $(($OPTIND-1)) handle_common_flags mkrc $version $verbosity if [ $in_host -eq 1 -a "x$tag" != "x" ]; then $ERROR 1 "Cannot specify both -o and -t" fi if [ $always_copy -eq 1 ]; then INSTALL="$INSTALL -C" fi files=$@ for file in $files; do dotless=`echo $file | sed -e "s|$DEST_DIR/||" | sed -e 's/^\.//'` dest=`destination $DOTFILES_DIR $dotless $in_host $tag` mkdir -p $dest/`dirname $dotless` $MV $file $dest/$dotless $INSTALL -d $DOTFILES_DIR -t ${tag:--} $dotless done