-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall-dotfiles.sh
executable file
·45 lines (35 loc) · 1.1 KB
/
install-dotfiles.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
source_dir="$HOME/dotfiles"
target_dir="$HOME"
symlinks=(.colors .i3 .ncmpcpp .oh-my-zsh .vim_runtime .weechat .bashrc .dircolors .functions .mongorc.js tmux-cheatsheet .tmux.conf vim-cheatsheet .vimrc .xinitrc .Xresources .zsh_aliases .zshrc .zshrc.zni .zsh-update)
plugins=()
append() {
plugins+=($1)
}
get_files() {
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' > tempfile
while read -ru 3 path_key path
do
url_key=$(echo "$path_key" | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
if [ ! -d "$path" ];
then
git clone "$url" "$path"
else
append "$path"
fi
done 3<tempfile
root=$(pwd)
for p in "${plugins[@]}"
do
cd "$p" && git pull origin master && cd "$root"
[[ "$p" =~ YouCompleteMe$ ]] && cd "$p" && git submodule update --init --recursive &&
./install.py --all
done
rm tempfile
}
get_files
for file in "${symlinks[@]}"; do
[[ -z $source_dir/$file ]] && ln -s "$source_dir/$file" "$target_dir/$file"
done