-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·42 lines (32 loc) · 905 Bytes
/
install
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
#!/bin/bash
__dir__="$(cd $(dirname "${BASH_SOURCE[0]}"); pwd)"
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
dotfile=${file/$root\/symlinks\//.}
echo "🔗 Linking '$dotfile'..."
mkdir -p $(dirname "$destination/$dotfile")
ln -sf $file "$destination/$dotfile"
done
}
inject_init() {
local init="$__dir__/init.sh"
local profile="$HOME/.profile"
touch $profile
if ! grep -q "peagha/dotfiles" $profile; then
echo "👉 Loading 'init.sh' on your '~/.profile'..."
echo -e "# Added by peagha/dotfiles\ntest -f $init && source $init\n" >> $profile
fi
}
create_directories() {
mkdir -p $HOME/Code/{me,oss,work}
echo "👉 Creating directories on '~/Code'..."
}
link_files $__dir__
inject_init
create_directories
echo "🎉 Done!"