-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotfilesLink.sh
executable file
·101 lines (71 loc) · 2.03 KB
/
dotfilesLink.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
set -e
set -u
BOLD=$(tput bold)
BLUE=$(tput setaf 4)
NORMAL=$(tput sgr0)
printReport() {
printf "${BLUE}==>${NORMAL} ${BOLD}${1}${NORMAL}\n"
}
setupDotFiles() {
printReport "Start setupDotFiles"
dotfiles=$HOME/dotfiles
neobundle=$dotfiles/targets/.vim/neobundle.vim
neobundleReadMe=$neobundle/README.md
targets=$dotfiles/targets/\.*
has() {
type "$1" > /dev/null 2>&1
}
symlink() {
[ -e "$2" ] || ln -sf "$1" "$2"
}
if [ -d "$dotfiles" ]; then
(cd "$dotfiles" && git pull)
else
git clone https://github.com/yukihirai0505/dotfiles "$dotfiles"
fi
if [ ! -e "$neobundleReadMe" ]; then
git clone https://github.com/Shougo/neobundle.vim "$neobundle"
fi
for target in ${targets[@]}; do
targetName=$(basename $target)
symlink "$target" "$HOME/$targetName"
done
printReport "Finish setupDotFiles"
}
setupLocalCommands() {
printReport "Start setupLocalCommands"
files=$dotfiles/.local/command/*
for filepath in $files; do
commandName=$(basename $filepath)
if [ ! `which $commandName` ]; then
ln -si $filepath /usr/local/bin
fi
done
printReport "Finish setupLocalCommands"
}
setUpSources() {
printReport "Start setUpSources"
sourceDir=$dotfiles/source
files=$sourceDir/*
for filepath in $files; do
if [ -f $filepath ]; then
if [ `echo $filepath | grep '\.zip'` ] ; then
if [ ! -d `echo $filepath | sed -e "s/\.zip//"` ] ; then
unzip $filepath -d $sourceDir/
fi
fi
if [ `echo $filepath | grep '\-bin\.tar\.gz'` ] ; then
if [ ! -d `echo $filepath | sed -e "s/-bin\.tar\.gz//"` ] ; then
tar vxf $filepath -C $sourceDir/
fi
fi
fi
done
printReport "Finish setUpSources"
}
printReport "I wanna eat 🍣 "
setupDotFiles
setupLocalCommands
setUpSources
printReport "Let's eat 🍣 "