diff options
Diffstat (limited to '')
-rwxr-xr-x | link.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/link.sh b/link.sh new file mode 100755 index 00000000..0f1f49aa --- /dev/null +++ b/link.sh @@ -0,0 +1,18 @@ +#!/bin/sh +set -e -u + +if [ $# -eq 1 ]; then + linkPath=$1 + filePath="$PWD/home/${linkPath#$HOME/}" + [ ! -f "$filePath" ] + mkdir -p "$(dirname "$filePath")" + mv "$linkPath" "$filePath" +fi + +find home -type f | while read -r findPath; do + filePath="$PWD/$findPath" + linkPath="$HOME/${findPath#home/}" + mkdir -p "$(dirname "$linkPath")" + [ \( -f "$linkPath" -a -L "$linkPath" \) -o ! -f "$linkPath" ] + ln -s -f "$filePath" "$linkPath" +done |