summary refs log tree commit diff
path: root/link.sh
blob: d74f478882cdd9fe509a6fef3d6ffb24095f8895 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh
set -eu

if [ $# -eq 1 ]; then
	link=$1
	file="${PWD}/home/${link#${HOME}/}"
	[ ! -f "$file" ]
	mkdir -p "${file%/*}"
	mv "$link" "$file"
fi

find home -type f | while read -r find; do
	file="${PWD}/${find}"
	link="${HOME}/${find#home/}"
	mkdir -p "${link%/*}"
	[ \( -f "$link" -a -L "$link" \) -o ! -f "$link" ]
	ln -fs "$file" "$link"
done