From 3a7a6d89708a62ca2efd8b36dd44fa30d461f23a Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Wed, 14 Mar 2018 21:53:11 -0400 Subject: Clean up home scripts, split again --- link.zsh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 link.zsh (limited to 'link.zsh') diff --git a/link.zsh b/link.zsh new file mode 100755 index 00000000..42c8d04c --- /dev/null +++ b/link.zsh @@ -0,0 +1,19 @@ +#!/usr/bin/env zsh +set -o errexit -o nounset -o pipefail + +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 findPath; do + filePath="$PWD/$findPath" + linkPath="$HOME/${findPath#home/}" + [ -L "$linkPath" ] && continue + mkdir -p $(dirname "$linkPath") + ln -s "$filePath" "$linkPath" + echo "$linkPath" +done -- cgit 1.4.1