summary refs log tree commit diff
path: root/link.zsh
blob: 42c8d04cc0720019031849dbc86c7fd398e5ec70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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