Skip to content

Commit 4cb7666

Browse files
committed
Create global .gitignore file
We'll also wrap everything in a `setup` function to delay the script execution until the very end. This way the script will not be run until the whole file is downloaded.
1 parent f73b20b commit 4cb7666

File tree

1 file changed

+70
-46
lines changed

1 file changed

+70
-46
lines changed

install.sh

Lines changed: 70 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# 5. check for maven and tomcat, install them with brew if not present
1414
# 6. check for mysql, install it and configure if not present
1515
# 7. install node with brew
16+
# 8. setup a global gitignore file
1617

1718
wait-to-continue(){
1819
echo
@@ -83,11 +84,11 @@ setup-ssh-keys(){
8384
echo "to the GitHub website where you will add it as one of your keys by clicking the"
8485
echo '"New SSH key" button, giving the key a title (for example: Macbook-Pro), and'
8586
echo 'pasting the key into the "key" textarea.'
86-
echo 'Once you have done all of the above, click the big green "Add SSH key" button'
87-
echo 'then come back here.'
88-
8987
wait-to-continue
9088
open https://github.com/settings/ssh
89+
90+
echo 'Once you have done all of the above, click the big green "Add SSH key" button'
91+
echo 'then come back here.'
9192
wait-to-continue
9293
}
9394

@@ -120,46 +121,69 @@ install-node() {
120121
brew install node
121122
}
122123

123-
echo 'We are going to check if xcode and brew are installed, and if you have ssh keys setup.'
124-
echo 'We will then setup our java development environment, including installing MySQL.'
125-
echo ''
126-
echo 'All together we will be installing: '
127-
echo ' - xcode tools - brew'
128-
echo ' - java - maven'
129-
echo ' - tomcat - mysql'
130-
echo ' - node'
131-
echo '*Note*: if you have already setup any of the above on your computer, this script will _not_'
132-
echo ' attempt to reinstall them, please talk to an instructor to ensure everything'
133-
echo ' is configured properly'
134-
echo ''
135-
echo 'During this process you may be asked for your password several times. This is the password'
136-
echo 'you use to log into your computer. When you type it in, you will not see any output in the'
137-
echo 'terminal, this is normal.'
138-
wait-to-continue
139-
140-
# check for xcode, brew, and ssh keys and run the relevant installer functions
141-
# if they do not exist
142-
xcode-select --print-path >/dev/null 2>&1 || install-xcode
143-
which brew >/dev/null 2>&1 || install-brew
144-
[ -d $HOME/.ssh ] && [ -f $HOME/.ssh/id_rsa ] || setup-ssh-keys
145-
146-
# check if java was installed with brew cask if not install it
147-
brew cask list java >/dev/null 2>&1 || install-java
148-
# check for tomcat, maven, and mysql
149-
which mvn >/dev/null || install-maven
150-
which catalina >/dev/null || install-tomcat
151-
which mysql >/dev/null || install-mysql
152-
# and lastly, node
153-
which node >/dev/null || install-node
154-
155-
echo "Ok! We've gotten everything setup and you should be ready to go!"
156-
echo "Good luck in class!"
157-
echo
158-
echo " _____ _____ _ _ "
159-
echo " | __ \\ / __ \\ | | | |"
160-
echo " | | \\/ ___ | / \\/ ___ __| | ___ _ _ _ __ | |"
161-
echo " | | __ / _ \\ | | / _ \\ / _ |/ _ \\ | | | '_ \\| |"
162-
echo " | |_\\ \\ (_) | | \\__/\\ (_) | (_| | __/ |_| | |_) |_|"
163-
echo " \\____/\\___/ \\____/\\___/ \\__,_|\\___|\\__,_| .__/(_)"
164-
echo " | | "
165-
echo " |_| "
124+
setup() {
125+
echo 'We are going to check if xcode and brew are installed, and if you have ssh keys setup.'
126+
echo 'We will then setup our java development environment, including installing MySQL,'
127+
echo 'and a mild bit of git configuration.'
128+
echo ''
129+
echo 'All together we will be installing: '
130+
echo ' - xcode tools - brew'
131+
echo ' - java - maven'
132+
echo ' - tomcat - mysql'
133+
echo ' - node'
134+
echo '*Note*: if you have already setup any of the above on your computer, this script will _not_'
135+
echo ' attempt to reinstall them, please talk to an instructor to ensure everything'
136+
echo ' is configured properly'
137+
echo ''
138+
echo 'During this process you may be asked for your password several times. This is the password'
139+
echo 'you use to log into your computer. When you type it in, you will not see any output in the'
140+
echo 'terminal, this is normal.'
141+
wait-to-continue
142+
143+
# check for xcode, brew, and ssh keys and run the relevant installer functions
144+
# if they do not exist
145+
xcode-select --print-path >/dev/null 2>&1 || install-xcode
146+
which brew >/dev/null 2>&1 || install-brew
147+
[ -d $HOME/.ssh ] && [ -f $HOME/.ssh/id_rsa ] || setup-ssh-keys
148+
149+
# check if java was installed with brew cask if not install it
150+
brew cask list java >/dev/null 2>&1 || install-java
151+
# check for tomcat, maven, and mysql
152+
which mvn >/dev/null || install-maven
153+
which catalina >/dev/null || install-tomcat
154+
which mysql >/dev/null || install-mysql
155+
# and lastly, node
156+
which node >/dev/null || install-node
157+
158+
# setup the global gitignore file
159+
if git config --global -l | grep core.excludesfile >/dev/null ; then
160+
echo 'It looks like you already have a global gitignore file setup (core.excludesfile).'
161+
echo 'We will not modify it, but make sure you have the following values in it:'
162+
echo
163+
echo ' .DS_Store'
164+
echo ' .idea'
165+
echo ' *.iml'
166+
echo
167+
else
168+
echo 'Setting up global gitignore file...'
169+
echo '.DS_Store' >> ~/.gitignore_global
170+
echo '.idea' >> ~/.gitignore_global
171+
echo '*.iml' >> ~/.gitignore_global
172+
git config --global core.excludesfile ~/.gitignore_global
173+
fi
174+
175+
echo "Ok! We've gotten everything setup and you should be ready to go!"
176+
echo "Good luck in class!"
177+
echo
178+
echo " _____ _____ _ _ "
179+
echo " | __ \\ / __ \\ | | | |"
180+
echo " | | \\/ ___ | / \\/ ___ __| | ___ _ _ _ __ | |"
181+
echo " | | __ / _ \\ | | / _ \\ / _ |/ _ \\ | | | '_ \\| |"
182+
echo " | |_\\ \\ (_) | | \\__/\\ (_) | (_| | __/ |_| | |_) |_|"
183+
echo " \\____/\\___/ \\____/\\___/ \\__,_|\\___|\\__,_| .__/(_)"
184+
echo " | | "
185+
echo " |_| "
186+
}
187+
188+
# delay script execution until the entire file is transferred
189+
setup

0 commit comments

Comments
 (0)