From e5d6dc30263fcf833713b6f227fd6d131b902ec1 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 16 Jul 2017 14:15:56 +0200 Subject: Add shell script to adopt dotfiles into repo --- adopt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 adopt diff --git a/adopt b/adopt new file mode 100755 index 00000000..94509c3d --- /dev/null +++ b/adopt @@ -0,0 +1,28 @@ +#!/bin/sh +DOTFILES_DIR=$(dirname $(readlink -f $0)) + +if [ "$#" -lt 2 ] +then + echo "usage: $(basename $0) tag file-to-adopt" + exit 1 +fi + +if [ -d $2 ] +then + TARGET="$DOTFILES_DIR/$1/$2" + if ! [ -d $TARGET ] + then + mkdir -p $TARGET + fi + mv $2/* $TARGET + ln -s $TARGET/* "$2" +elif [ -f $2 ] +then + TARGET="$DOTFILES_DIR/$1/$(dirname $2)" + if ! [ -d $TARGET ] + then + mkdir -p $TARGET + fi + mv $2 $TARGET + ln -s $TARGET/$(basename $2) +fi -- cgit 1.4.1