-
Notifications
You must be signed in to change notification settings - Fork 4
/
sync.sh
55 lines (50 loc) · 1.45 KB
/
sync.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
#!/usr/bin/env bash
sync(){
if [[ $1 == "local" ]]; then
sync_local_to_repo
elif [[ $1 == "repo" ]] || [[ $1 == "repository" ]]; then
sync_repo_to_local
else
announce "Sync.sh: A helper file to sync dotfiles betweenn repo and system"
message "local: Sync system to repo dotfiles"
message "repo: Sync repo to system's dotfiles"
fi
}
dotfiles=(
.vimrc
.zshrc
.zshenv
.tmux.conf.local
.gitconfig
.alacritty.yml
.gitignore
.dircolors
)
sync_repo_to_local(){
announce "Copying system's dotfiles to this repository.."
message "It will copy the following dotfiles: ${dotfiles[*]}"
for dotfile in ${dotfiles[*]}
do
cp -rf "${HOME}/${dotfile}" "${dotfile}"
done
rm -rf .vim && rm -rf .config/nvim
cp -R ~/.vim/ .vim/ 2>/dev/null
cp -R ~/.config/nvim .config/nvim/
message "Updating brew-apps.txt via brew leaves.."
brew leaves > brew-apps.txt
}
sync_local_to_repo(){
announce "Copying the dotfiles from this repository over to the system.."
message "It will copy the following dotfiles: ${dotfiles[*]}"
for dotfile in ${dotfiles[*]}
do
cp -rf "${dotfile}" "${HOME}/${dotfile}"
done
rm -rf ~/.vim && rm -rf ~/.config/nvim
cp -R .vim ~/.vim 2>/dev/null
cp -r .config/nvim/ ~/.config/nvim
message "Installing nvim plugins.."
warning "The error messages are normal, as the plugins haven't been installed yet"
nvim --headless +PlugInstall +qa
message "Nvim plugins have been installed"
}