-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync
executable file
·53 lines (45 loc) · 1.38 KB
/
sync
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
#!/usr/bin/env zsh
cmd=$1
append_zshrc () {
local rc_file="$HOME/.zshrc"
local line=$1
found=$(cat "$rc_file" | grep "$line")
if [[ -z "$found" ]]; then
echo -e "\n$line" >> "$rc_file"
fi
}
copy_and_backup () {
local src=$1
local dest="$HOME/$2"
local backup="$dest.backup"
if [[ -d "$backup" ]]; then
rm -r $backup || true
fi
if [[ -d "$dest" || -f "$dest" ]]; then
mv $dest $backup
echo "Backup $dest to $backup"
fi
cp -r "$src" "$dest"
echo "Updated $dest"
}
if [[ "$cmd" == "diff" ]]; then
diff -ruN --color=always ~/.tmux.conf tmux/.tmux.conf
diff -ruN --color=always ~/.config/nvim/init.vim nvim/init.vim
elif [[ "$cmd" == "get" ]]; then
cp -r ~/.config/i3 .
cp -r ~/.config/alacritty .
cp ~/.tmux.conf tmux/.tmux.conf
cp ~/.config/nvim/init.vim nvim/init.vim
elif [[ "$cmd" == "cp" ]]; then
copy_and_backup "nvim" ".config/nvim"
copy_and_backup "i3" ".config/i3"
copy_and_backup "alacritty" ".config/alacritty"
copy_and_backup "tmux/.tmux.conf" ".tmux.conf"
copy_and_backup "tmux/config" ".config/tmux"
copy_and_backup "bin" ".local/bin"
copy_and_backup "zsh/.zshrc" ".zshrc"
copy_and_backup "nu" ".config/nu"
copy_and_backup "nu/starship.toml" ".config/starship.toml"
#append_zshrc "export PATH=\$PATH:\$HOME/.local/bin"
source "$HOME/.zshrc"
fi