summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2017-07-16 14:15:56 +0200
committerAlan Pearce2017-07-16 14:15:56 +0200
commite5d6dc30263fcf833713b6f227fd6d131b902ec1 (patch)
treec416126e49771be55818f42ca86e3e797bd5051b
parent7c98a8f79a3f24a0ab23c6d8f1283c5488557ec3 (diff)
downloaddotfiles-e5d6dc30263fcf833713b6f227fd6d131b902ec1.tar.lz
dotfiles-e5d6dc30263fcf833713b6f227fd6d131b902ec1.tar.zst
dotfiles-e5d6dc30263fcf833713b6f227fd6d131b902ec1.zip
Add shell script to adopt dotfiles into repo
-rwxr-xr-xadopt28
1 files changed, 28 insertions, 0 deletions
diff --git a/adopt b/adopt
new file mode 100755
index 0000000..94509c3
--- /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