diff options
author | June McEnroe <june@causal.agency> | 2018-03-14 21:53:11 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-03-14 21:53:50 -0400 |
commit | e5101601fa06513a286645b7bfec2f885c9d54ed (patch) | |
tree | 23d2b4adcf8f050e518a7c4ceef38374cbdea4f3 /link.zsh | |
parent | Clean up install.sh (diff) | |
download | src-e5101601fa06513a286645b7bfec2f885c9d54ed.tar.gz src-e5101601fa06513a286645b7bfec2f885c9d54ed.zip |
Clean up home scripts, split again
Diffstat (limited to '')
-rwxr-xr-x | link.zsh | 19 |
1 files changed, 19 insertions, 0 deletions
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 |