-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathback
executable file
·181 lines (156 loc) · 4.93 KB
/
back
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/usr/bin/env zsh
# only use rsync
#usage: "back _function"
#rsync option
#-v : print log
#-h : human readable
#-a : archive mode : -r, -t(타임스탬프 보존), -l (심볼릭 링크 보존), -p(permission 보존), -g(g그룹 보존), -o(소유자 보존 - root 만 가능), -D(device, special 파일 보존)과 동일
#-z : compress
#-r : recurse into directories
#-b : backup --suffix ~
#-u : skip files that are newer on the receiver
#-R : use relative path naems
#-L : symbolic link를 따라가서 원본 파일을 복제
help(){
echo "Usage: back [OPTIONS] [GROUP_NAME]
Back up the specified dotfile groups to the dotfiles repository using rsync with -azvhrubRL options.
Groups:
_git, _brew, _zsh, _vim, _fzf, _tmux, _gdb, _yarn, _python, _karabiner
Options:
-A, --all, all Back up all groups
-B, --basic, basic Back up a predefined set of essential groups
(_git, _brew, _zsh, _vim, _fzf, _tmux, _karabiner)"
}
_git(){
# cp -Riv --parents ~/.gitconfig ~/dotfiles/git/.gitconfig
# cp -Riv --parents ~/.gitignore_global ~/dotfiles/git/.gitignore_global
rsync -azvhrubR -L ~/./.gitconfig ~/dotfiles/_git
rsync -azvhrubR -L ~/./.gitignore_global ~/dotfiles/_git
}
_brew(){
rm ~/dotfiles/Brewfile~
rm ~/dotfiles/Brewmas~
mv ~/dotfiles/Brewfile ~/dotfiles/Brewfile~
mv ~/dotfiles/Brewmas ~/dotfiles/Brewmas~
brew bundle dump --force --file=~/./Brewfile
brew bundle --mas dump --force --file=~/./Brewmas
rsync -azvhrubR -L ~/./Brewfile ~/dotfiles/Brewfile
rsync -azvhrubR -L ~/./Brewmas ~/dotfiles/Brewmas
}
_zsh(){
# rsync -azvhrubR -L ~/./.zplug/ ~/dotfiles/_zsh
rsync -azvhrubR -L ~/./.zshenv ~/dotfiles/_zsh
rsync -azvhrubR -L ~/./.zshrc ~/dotfiles/_zsh
rsync -azvhrubR -L ~/./.oh-my-zsh/ ~/dotfiles/_zsh
}
_vim(){
rsync -azvhrubR -L ~/./.vimrc ~/dotfiles/_vim
# rsync -azvhrubR -L ~/./.vim/autoload/ ~/dotfiles/_vim
rsync -azvhrubR -L ~/./.vim/plugged/ ~/dotfiles/_vim
# rsync -azvhrubR -L ~/./.config/coc/extensions ~/dotfiles/_vim
rsync -azvhrubR -L ~/./.config/nvim/ ~/dotfiles/_vim
rsync -azvhrubR -L ~/./.local/share/nvim/session/ ~/dotfiles/_vim
rsync -azvhrubR -L ~/./.NERDTreeBookmarks ~/dotfiles/_vim
# rsync -azvhrubR -L ~/./.local/share/nvim/site ~/dotfiles/vim
# rsync -azvhrubR -L ~/./.viminfo/ ~/dotfiles/vim
}
_fzf(){
# cp -Riv --parents ~/.fzfignore ~/dotfiles/fzf/.fzfignore
# cp -Riv --parents ~/.fzf.zsh ~/dotfiles/fzf/.fzf.zsh
rsync -azvhrubR -L ~/./.fzfignore/ ~/dotfiles/_fzf
rsync -azvhrubR -L ~/./.fzf.zsh/ ~/dotfiles/_fzf
}
_tmux(){
# cp -Riv --parents ~/.tmux.conf ~/dotfiles/tmux/.tmux.conf
rsync -azvhrubR -L ~/./.tmux.conf ~/dotfiles/_tmux
# rsync -azvhrubR -L ~/./.tmux/plugins/ ~/dotfiles/tmux
}
_gdb(){
# cp -Riv --parents ~/.gdbinit ~/dotfiles/gdb/.gdbinit
# cp -Riv --parents ~/gdb.xml ~/dotfiles/gdb/gdb.xml
# cp -Riv --parents ~/makefile ~/dotfiles/gdb/makefile
rsync -azvhrubR -L ~/./.gdbinit ~/dotfiles/_gdb
rsync -azvhrubR -L ~/./gdb.xml ~/dotfiles/_gdb
rsync -azvhrubR -L ~/./makefile ~/dotfiles/_gdb
}
_yarn(){
# cp -Riv --parents ~/.yarn ~/dotfiles/nodejs/.yarn
# cp -Riv --parents ~/.nvm ~/dotfiles/nodejs/.nvm
# cp -Riv --parents ~/.config/yarn ~/dotfiles/nodejs/.config/yarn
# cp -Riv --parents ~/.config/gatsby ~/dotfiles/nodejs/.config/gatsby
# cp -Riv --parents ~/.config/configstore ~/dotfiles/nodejs/.config/configstore
# rsync -azvhrubR -L ~/./.nvm/ ~/dotfiles/_yarn
rsync -azvhrubR -L ~/./.yarn/yarn.lock ~/dotfiles/_yarn
rsync -azvhrubR -L ~/./.yarn/package.json ~/dotfiles/_yarn
# rsync -azvhrubR -L ~/./.yarnrc ~/dotfiles/_yarn
# rsync -azvhrubR -L ~/./.config/gatsby/ ~/dotfiles/_yarn
# rsync -azvhrubR -L ~/./.config/configstore/ ~/dotfiles/_yarn
}
_python(){
rsync -azvhrubR -L ~/./.pyenv/version/ ~/dotfiles/_python
# rsync -azvhrubR -L ~/./piplist ~/dotfiles/_python
}
_karabiner(){
rsync -azvhrubR -L ~/./.config/karabiner/assets ~/dotfiles/_karabiner
rsync -azvhrubR -L ~/./.config/karabiner/karabiner.json ~/dotfiles/_karabiner
}
_docker(){
rsync -azvhrubR -L ~/./.docker/ ~/dotfiles/_docker
}
_rclone(){
rsync -azvhrubR -L ~/./rclone_mount.sh ~/dotfiles/_rclone
rsync -azvhrubR -L ~/./rclone_umount.sh ~/dotfiles/_rclone
rsync -azvhrubR -L ~/./.config/rclone ~/dotfiles/_rclone
}
_etc(){
echo "etc"
# rsync -azvhrubR -L ~/./.fasd ~/dotfiles/_etc
# rsync -azvhrubR -L ~/./.notable.json/ ~/dotfiles/_etc
# rsync -azvhrubR -L ~/./.skhdrc ~/dotfiles/_etc
# rsync -azvhrubR -L ~/./.yabairc ~/dotfiles/_etc
}
all(){
_git
_brew
_zsh
_vim
_fzf
_tmux
_gdb
_yarn
_python
_rclone
_etc
}
basic(){
_git
_brew
_zsh
_vim
_fzf
_tmux
_karabiner
}
main(){
if [ $# -eq 0 ]; then
help
elif [ $# -gt 0 ]; then
case $1 in
-h|--help|help)
help
return 0
;;
-B|--basic|basic)
basic
;;
-A|--all|all)
all
;;
*)
"$@"
;;
esac
shift
fi
}
main "$@"