-
Notifications
You must be signed in to change notification settings - Fork 1
/
coder.sh
executable file
·238 lines (193 loc) · 6.43 KB
/
coder.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
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/bash
# disables the display of keyboard input
stty -echo
red=$'\e[1;31m'
grn=$'\e[1;32m'
yel=$'\e[1;33m'
blu=$'\e[1;34m'
mag=$'\e[1;35m'
cyn=$'\e[1;36m'
end=$'\e[0m'
declare -i selection
selection=0
nodeMenu=1
menuOptions=(
"Run everything!"
"Install git, vim, zsh"
"Install Vim Powerline, Plugins and Fonts"
"Install Oh-My-Zsh"
"Insert ZSH Aliases for TMS Docker Compose"
"Init the repos!"
"Exit"
)
function allofem {
installgitvimzsh
vimthemes
ohmyzsh
insertaliases
repos
}
function installgitvimzsh {
clear
sudo apt-get install git vim zsh
read -r -s -p $'Press enter to continue...'
echo "done!"
}
function vimthemes {
clear
echo "Do you need to generate an ssh key?"
read -p "Start? (y/n) > " choice
case "$choice" in
y|Y ) ssh-keygen
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub
echo "Now would be a good time to copy that to bitbucket or github..."
read -p "Continue..."
;;
n|N|* ) echo "Ok..."
;;
esac
git clone git://github.com/froggr/vim.git ~/.vim
ln -s ~/.vim/vimrc ~/.vimrc
cd ~/.vim
git submodule init
git submodule update
open Inconsolata-dz-Powerline.otf
cd ~/
git clone https://github.com/scotu/ubuntu-mono-powerline.git ~/.fonts
fc-cache
echo "Done. Vim should be good to go"
}
function ohmyzsh {
clear
curl -L http://install.ohmyz.sh | sh
curl -o ~/.oh-my-zsh/themes/frog.zsh-theme 'https://raw.githubusercontent.com/froggr/dots/master/files/frog.zsh-theme'
sed -i.bu 's/robbyrussell/frog/g' ~/.zshrc
sed -i.bu 's/plugins\(git\)/plugins\=\(git docker docker-compose zsh-syntax-highlighting zsh-autosuggestions\)/g' ~/.zshrc
echo "alias ll=\"ls -la\"" >> ~/.zshrc
sudo chsh -s $(which zsh) $USER
brew install fzf
$(brew --prefix)/opt/fzf/install
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
echo "Done the install. If the theme wasnt changed to bira, vim the .zshrc file and change er"
}
function insertaliases {
echo "Here we go..."
cat <<EOT >> ~/.zshrc
alias dcshell="docker compose -f ~/projects/TMS_docker-compose/docker-compose.yml --project-directory /var/www/html exec app bash"
alias dcmysql="docker compose -f ~/projects/TMS_docker-compose/docker-compose.yml exec app bash -c 'mysql -uroot -ppassword -h db'"
alias php7="sudo update-alternatives --set php /usr/bin/php7.4"
alias php8="sudo update-alternatives --set php /usr/bin/php8.2"
alias dc="docker compose -f ~/projects/TMS_docker-compose/docker-compose.yml"
dcnpm() {
docker compose -f ~/projects/TMS_docker-compose/docker-compose.yml exec app bash -c "cd /var/www/html && npm \$*"
}
artisan() {
docker compose -f ~/projects/TMS_docker-compose/docker-compose.yml exec app bash -c "cd /var/www/html && php artisan \$*"
}
EOT
}
function repos {
mkdir ~/projects
cd ~/projects
git clone [email protected]:timelessgroup/TMS_docker-compose.git
git clone [email protected]:Timeless-Medical-International/wai-web.git
git clone [email protected]:timelessgroup/Version-7.git
cp ~/projects/TMS_docker-compose/example_env ~/projects/TMS_docker-compose/.env
cd ~/
}
function menu {
echo -e "${grn}"
echo -e "Frogs Dots!"
echo -e "${end}"
echo -e "\t${yel}Select a menu option and hit return:${end}\n"
}
# Renders a text based list of options that can be selected by the
# user using up, down and enter keys and returns the chosen option.
#
# Arguments : list of options, maximum of 256
# "opt1" "opt2" ...
# Return value: selected index (0 for opt1, 1 for opt2 ...)
function select_option {
# little helpers for terminal print control and key input
ESC=$( printf "\033")
cursor_blink_on() { printf "$ESC[?25h"; }
cursor_blink_off() { printf "$ESC[?25l"; }
cursor_to() { printf "$ESC[$1;${2:-1}H"; }
print_option() { printf " $1 "; }
print_selected() { printf " $ESC[7m $1 $ESC[27m"; }
get_cursor_row() { IFS=';' read -sdR -p $'\E[6n' ROW COL; echo ${ROW#*[}; }
key_input() { read -s -n3 key 2>/dev/null >&2
if [[ $key = $ESC[A ]]; then echo up; fi
if [[ $key = $ESC[B ]]; then echo down; fi
if [[ $key = "" ]]; then echo enter; fi; }
# initially print empty new lines (scroll down if at bottom of screen)
for opt; do printf "\n"; done
# determine current screen position for overwriting the options
local lastrow=`get_cursor_row`
local startrow=$(($lastrow - $#))
# ensure cursor and input echoing back on upon a ctrl+c during read -s
trap "cursor_blink_on; stty echo; printf '\n'; exit" 2
cursor_blink_off
local selected=0
while true; do
# print options by overwriting the last lines
local idx=0
for opt; do
cursor_to $(($startrow + $idx))
if [ $idx -eq $selected ]; then
print_selected "$opt"
else
print_option "$opt"
fi
((idx++))
done
# user key control
case `key_input` in
enter) break;;
up) ((selected--));
if [ $selected -lt 0 ]; then selected=$(($# - 1)); fi;;
down) ((selected++));
if [ $selected -ge $# ]; then selected=0; fi;;
esac
done
# cursor position back to normal
cursor_to $lastrow
printf "\n"
cursor_blink_on
return $selected
}
# takes an array and loads the menu
function select_opt {
select_option "$@" 1>&2
local result=$?
echo $result
return $result
}
while [ 1 ]
do
clear
menu
case `select_opt "${menuOptions[@]}"` in
0)
allofem ;;
1)
installgitvimzsh ;;
2)
vimthemes ;;
3)
ohmyzsh ;;
4)
insertaliases ;;
5)
repos ;;
6)
break;;
esac
echo -e "\n\n"
read -r -s -p $'Press enter to continue...'
done
clear
# https://unix.stackexchange.com/questions/146570/arrow-key-enter-menu
# this is awesome