-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·46 lines (35 loc) · 1013 Bytes
/
setup
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
#!/bin/bash
__dir__="$(git rev-parse --absolute-git-dir | sed 's/\/.git//')"
link_files() {
local root=$1;
local destination=$HOME;
if [ ! -d "$root/symlinks" ]; then
return 1
fi
for file in $(find $root/symlinks -type f -maxdepth 2); do
filename=${file/$root\/symlinks\//.}
src=${file/$HOME/"~"}
echo "🔗 Linking '$src'..."
mkdir -p $(dirname "$destination/$filename")
ln -sf $file "$destination/$filename"
done
}
inject_init() {
local init="$__dir__/init.zsh"
local profile="$HOME/.zshrc"
touch $profile
if ! grep -q "lucasmazza/dotfiles" $profile; then
echo "👉 Loading 'init.zsh' on your '~/.zshrc'..."
echo -e "# Added by lucasmazza/dotfiles\ntest -f $init && source $init\n" >> $profile
fi
}
create_directories() {
echo "👉 Creating directories on '~/src'..."
mkdir -p $HOME/src/{me,oss,work,heroku}
}
link_files $__dir__
link_files "$HOME/Dropbox"
inject_init
create_directories
. $__dir__/script/macos-custom
echo "🎉 Done!"