all repos — nixfiles @ 5d314760c15cb68ca79f38a1b019d155ef961e62

System and user configuration, managed by nix and home-manager

adopt (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
DOTFILES_DIR=$(dirname $(readlink -f $0))
STOW="$DOTFILES_DIR/stow"

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
  $STOW $1
elif [ -f $2 ]
then
  TARGET="$DOTFILES_DIR/$1/$(dirname $2)"
  if ! [ -d $TARGET ]
  then
    mkdir -p $TARGET
  fi
  mv $2 $TARGET
  $STOW $1
fi