-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·32 lines (28 loc) · 848 Bytes
/
setup
File metadata and controls
executable file
·32 lines (28 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
force=$1
source_dir="$( cd "$( dirname "$0" )" && pwd )"
this_script="$(basename "$0")"
skip_list=($this_script ".git" ".lock" ".emacs.desktop")
cd $source_dir
find_cmd="find . -type f -name '*'"
for skip in "${skip_list[@]}"; do
if [ -f $skip ]; then
find_cmd="$find_cmd ! -path ./$skip"
elif [ -d $skip ]; then
find_cmd="$find_cmd ! -path ./${skip}/'*'"
fi
done
for result in $(eval $find_cmd)
do
# sed can take hashes in place of slashes
rel_path=$(echo $result | sed -E 's#^./##g')
file=$(echo $rel_path | sed -E 's#.*/([^/]*$)#\1#g')
dir=$(echo $rel_path | sed -E 's#(.*)/[^/]*$#\1#g')
if [ "$file" = "$dir" ]; then
ln $force -s "$source_dir/$file" ~/".$file"
else
mkdir -p ~/.$dir
ln $force -s "$source_dir/$dir/$file" ~/.$dir/$file
fi
done
cd -