diff options
Diffstat (limited to '')
-rwxr-xr-x | link.zsh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/link.zsh b/link.zsh new file mode 100755 index 00000000..e9fa64ca --- /dev/null +++ b/link.zsh @@ -0,0 +1,18 @@ +#!/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 -r findPath; do + filePath="$PWD/$findPath" + linkPath="$HOME/${findPath#home/}" + mkdir -p "$(dirname "$linkPath")" + [[ ( -f "$linkPath" && -L "$linkPath" ) || ! -f "$linkPath" ]] + ln -s -f "$filePath" "$linkPath" +done |