-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy
188 lines (157 loc) · 5.56 KB
/
copy
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
182
183
184
185
186
187
188
#!/bin/bash
# RUN WITH
# `bash copy` zippin stuff up to ~/Downloads/tmp-files.zip
# `bash copy setup` replace dotfiles from ~/Downloads/tmp-files.zip & some setup
# `bash copy paste` replace dotfiles from ~/Downloads/tmp-files.zip
# `bash copy dotfile(s)` unzippin stuff from ~/Downloads/tmp-files.zip
# args=("$@") , create array variable
# test
# rm -rf ~/tmp-files
# mkdir ~/tmp-files
# unzip ~/Downloads/tmp-files.zip -d ~/tmp-files
function copy_create_zip() {
echo "cleaning up"
rm -rf ~/tmp-files/*
mkdir -p ~/tmp-files
echo "movin stuff"
cp ~/.alacritty.yml ~/tmp-files/.alacritty.yml
cp -R ~/.tmux.conf ~/tmp-files/.tmux.conf
cp ~/.vimrc ~/tmp-files/.vimrc
cp ~/.zshrc ~/tmp-files/.zshrc
cp ~/settings.json ~/tmp-files/settings.json
cp ~/.brew ~/tmp-files/.brew
cp ~/.notion-enhancer ~/tmp-files/.notion-enhancer
cp ~/startup.ahk ~/tmp-files/startup.ahk
echo "cvim"
mkdir ~/tmp-files/cvim
git clone https://gist.github.com/drkdi/4e03d5828cce47d42d54f9c5507479d1 ~/tmp-files/cvim
rm -rf ~/tmp-files/cvim/.git
echo "inception"
cp ~/copy ~/tmp-files/copy
echo "movin directories"
#mkdir ~/tmp-files/.tmux
#cp -R ~/.tmux ~/tmp-files
mkdir ~/tmp-files/.config
mkdir ~/tmp-files/.config/nvim
cp -R ~/.config/nvim/init.vim ~/tmp-files/.config/nvim/init.vim
mkdir ~/tmp-files/.vim
cp ~/.vim/coc-settings.json ~/tmp-files/.vim/coc-settings.json
cp ~/.vim/plugins.vim ~/tmp-files/.vim/plugins.vim
cp ~/.vim/coc-plugin.vim ~/tmp-files/.vim/coc-plugin.vim
echo "delete all other than most recent bttpreset in /Downloads, copy to tmp-file, then delete"
# to find most recent is `ls -Art ~/Downloads/*.bttpreset | tail -n 1`
ls -t ~/Downloads/*.bttpreset | tail -n +2 | xargs rm -f
find ~/Downloads -type f -name "*.bttpreset" -maxdepth 1 -exec cp "{}" ~/tmp-files/$(date +"%m-%d-%y").bttpreset \;
}
function clean_up() {
echo "cleaning up"
cd ~/tmp-files
zip -r -FS ~/tmp-files.zip .
cp ~/tmp-files.zip ~/Downloads/tmp-files.zip
rm -rf ~/tmp-files
echo "done!"
echo "file created in ~/Downloads/tmp-files.zip"
}
function personal_and_clean_up() {
echo "don't put to git"
cp ~/Derek.bettertouchtool ~/tmp-files/Derek.bettertouchtool
cp ~/DankMono-Italic-Nerd-Font-Mono.otf ~/tmp-files/DankMono-Italic-Nerd-Font-Mono.otf
cp ~/DankMono-Regular-Nerd-Font-Mono.otf ~/tmp-files/DankMono-Regular-Nerd-Font-Mono.otf
mkdir -p ~/tmp-files/.config/tmuxinator
cp -R ~/.config/tmuxinator ~/tmp-files/.config
echo "cleaning up"
cd ~/tmp-files
zip -r -FS ~/tmp-files.zip .
cp ~/tmp-files.zip ~/Downloads/tmp-files-PERSONAL.zip
rm -rf ~/tmp-files
echo "done!"
echo "file created in ~/Downloads/tmp-files-PERSONAL.zip"
}
function unzippem() {
echo "unzippin to ~/ root directory"
if [[ $2 == *"personal"* ]]
then
unzip -o '~/Downloads/tmp-files-PERSONAL.zip' -d ~
else
unzip -o '~/Downloads/tmp-files.zip' -d ~
fi
}
# function install_brew() {
# if brew ls --versions myformula > /dev/null; then
# The package is installed
# else
# The package is not installed
# fi
# }
function setup() {
echo "setting up for the first time"
echo "installing homebrew and brew files"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
for a in $(cat .brew); do brew list $a || brew install $a; done
echo "installing .bttpreset"
ls -t ~/*.bttpreset | tail -n +1 | xargs open
echo "installing fonts"
ls -t ~/*.otf | tail -n +1 | xargs open
echo "keyboard stuff"
defaults write -g InitialKeyRepeat -int 10
# normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 1
# normal minimum is 2 (30 ms)
defaults write -g ApplePressAndHoldEnabled -bool false
}
function paste() {
rm ~/*.bttpreset
# only keep most recent tmp-files*.zip
ls -t ~/Downloads/tmp-files*.zip | tail -n +2 | xargs -I{} rm -v {}
if [[ $2 == *"force"* ]]
then
unzip -o ~/Downloads/tmp-files*.zip -d ~
else
# vim command: do (other into current) / dp (current into other)
mkdir -p ~/tmp-files & unzip -o ~/Downloads/tmp-files*.zip -d ~/Downloads/tmp-files
for files in $(diff -rq ~ ~/Downloads/tmp-files | grep 'differ$' | sed "s/^Files //g;s/ differ$//g;s/ and /:/g"); do
if [[ "${files%.*}" == *"DS"* || "${files%.*}" == *"cvim"* ]]
then continue
fi
vimdiff ${files%:*} ${files#*:};
done
fi
}
function save_dotfiles() {
# need to use '. ./copy dotfiles' with double [[ for current path to cd
echo "finding path"
for DIR in $(find ~/Desktop -type d -name "dotfiles")
do
cd $DIR
rm *.bttpreset
unzip -o ~/Downloads/tmp-files.zip -d "$DIR"
git add .
git commit -m "update"
git push
done
}
if [ $# -eq 0 ]
then
copy_create_zip
clean_up
else
if [[ $1 == *"personal"* ]]
then
echo "personal"
copy_create_zip
personal_and_clean_up
elif [ $1 = "setup" ]
then
setup
unzippem
elif [[ $1 == *"paste"* ]]
then
paste
elif [[ $1 == *"dotfile"* ]]
then
copy_create_zip
save_dotfiles
open https://github.com/drkdi/dotfiles/commit/main
fi
fi