forked from Wentzell/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
link.sh
executable file
·45 lines (41 loc) · 1.19 KB
/
link.sh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
cd $(dirname $0)
# Function that links a file to $HOME, DELETING it there if it exists already
function linkFile() {
LINK_TO_NAME=$2
if [ -z $LINK_TO_NAME ]; then
LINK_TO_NAME=$1
fi
if [ -a $HOME/$LINK_TO_NAME ]; then
#echo "**** Found existing $LINK_TO_NAME, skipping..."
echo "**** Found existing $LINK_TO_NAME, deleting..."
rm -rf $HOME/$LINK_TO_NAME
echo "Linking $1 to $LINK_TO_NAME"
ln -s $PWD/$1 $HOME/$LINK_TO_NAME
elif [ -h $HOME/$LINK_TO_NAME ]; then
echo "Already symlinked $LINK_TO_NAME, skipping..."
else
echo "Linking $1 to $LINK_TO_NAME"
ln -s $PWD/$1 $HOME/$LINK_TO_NAME
fi
}
# Link files to home and exclude the ones containing certain strings
for F in $(ls -a1 | \
grep -v '.git$' | \
grep -v disabled | \
grep -v .gitmodules | \
grep -v .gitignore | \
grep -v .dropbox | \
grep -v .bashrc | \
grep -v setup.sh | \
grep -v link.sh | \
grep -v Desktop | \
grep -v pkglst | \
grep -v aurlst | \
grep -v piplst | \
grep -v brewlst | \
egrep -v "^..?$" | \
egrep -v "^.*un~$" | \
grep -v .DS_Store \
); do linkFile $F
done