-
Notifications
You must be signed in to change notification settings - Fork 60
/
mac-setup-all.sh
executable file
·5496 lines (4560 loc) · 205 KB
/
mac-setup-all.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/local/bin/bash
# mac-setup-all.sh in https://github.com/wilsonmar/mac-setup
# This downloads and installs all the utilities related to use of Git,
# customized based on specification in file secrets.sh within the same repo.
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/wilsonmar/mac-setup/master/mac-setup-all.sh)"
# See https://github.com/wilsonmar/git-utilities/blob/master/README.md
# Based on https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
# and https://git-scm.com/docs/git-config
# and https://medium.com/my-name-is-midori/how-to-prepare-your-fresh-mac-for-software-development-b841c05db18
# https://www.bonusbits.com/wiki/Reference:Mac_OS_DevOps_Workstation_Setup_Check_List
# More at https://github.com/thoughtbot/laptop/blob/master/mac
# TOC: Functions (GPG_MAP_MAIL2KEY, Python, Python3, Java, Node, Go, Docker) >
# Starting: Secrets > XCode > XCode/Ruby > bash.profile > Brew > gitconfig > gitignore > Git web browsers > p4merge > linters > Git clients > git users > git tig > BFG > gitattributes > Text Editors > git [core] > git coloring > rerere > prompts > bash command completion > git command completion > Git alias keys > Git repos > git flow > git hooks > Large File Storage > gcviewer, jmeter, jprofiler > code review > git signing > Cloud CLI/SDK > Selenium > SSH KeyGen > SSH Config > Paste SSH Keys in GitHub > GitHub Hub > dump contents > disk space > show log
# set -o nounset -o pipefail -o errexit # "strict mode"
# set -u # -uninitialised variable exits script.
# set -e # -exit the script if any statement returns a non-true return value.
# set -a # Mark variables which are modified or created for export. Each variable or function that is created or modified is given the export attribute and marked for export to the environment of subsequent commands.
# set -v # -verbose Prints shell input lines as they are read.
IFS=$'\n\t' # Internal Field Separator for word splitting is line or tab, not spaces.
# shellcheck disable=SC2059
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
trap cleanup EXIT
trap sig_cleanup INT QUIT TERM
function fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\\n>>> $fmt\\n" "$@"
}
# From https://gist.github.com/somebox/6b00f47451956c1af6b4
function echo_ok { echo -e '\033[1;32m'"$1"'\033[0m'; }
function echo_warn { echo -e '\033[1;33m'"$1"'\033[0m'; }
function echo_error { echo -e '\033[1;31mERROR: '"$1"'\033[0m'; }
command_exists() {
command -v "$@" > /dev/null 2>&1
}
######### Starting time stamp, OS versions, command attributes:
# For Git on Windows, see http://www.rolandfg.net/2014/05/04/intellij-idea-and-git-on-windows/
TIME_START="$(date -u +%s)"
FREE_DISKBLOCKS_START="$(df | sed -n -e '2{p;q}' | cut -d' ' -f 6)"
THISPGM="mac-setup-all.sh"
# ISO-8601 plus RANDOM=$((1 + RANDOM % 1000)) # 3 digit random number.
LOG_DATETIME=$(date +%Y-%m-%dT%H:%M:%S%z)-$((1 + RANDOM % 1000))
LOGFILE="$HOME/$THISPGM.$LOG_DATETIME.log"
echo "$THISPGM starting with logging to file:" >$LOGFILE # new file
echo $LOGFILE >>$LOGFILE
clear # screen
echo $LOGFILE # to screen
RUNTYPE="" # value to be replaced with definition in secrets.sh.
#bar=${RUNTYPE:-none} # :- sets undefine value. See http://redsymbol.net/articles/unofficial-bash-strict-mode/
fancy_echo "sw_vers ::" >>$LOGFILE
echo "$(sw_vers)" >>$LOGFILE
echo "uname -a : $(uname -a)" >>$LOGFILE
function cleanup() {
err=$?
echo "At cleanup() LOGFILE=$LOGFILE"
#open -a "Atom" $LOGFILE
open -e $LOGFILE # open for edit using TextEdit
#rm $LOGFILE
trap '' EXIT INT TERM
exit $err
}
cleanup2() {
err=$?
echo "At cleanup2() LOGFILE=$LOGFILE"
# pico $LOGFILE
trap '' EXIT INT TERM
exit $err
}
sig_cleanup() {
echo "Run interrupted."
trap '' EXIT # some shells will call EXIT after the INT handler
false # sets $?
cleanup
}
#Mandatory:
# Ensure Apple's command line tools (such as cc) are installed by node:
if ! command_exists cc ; then
fancy_echo "Installing Apple's xcode command line tools (this takes a while) ..."
xcode-select --install
# Xcode installs its git to /usr/bin/git; recent versions of OS X (Yosemite and later) ship with stubs in /usr/bin, which take precedence over this git.
fi
xcode-select --version >>$LOGFILE
# XCode version: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/pkgutil.1.html
# pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version
# Tools_Executables | grep version
# version: 9.2.0.0.1.1510905681
# TODO: https://gist.github.com/tylergets/90f7e61314821864951e58d57dfc9acd
######### bash.profile configuration:
BASHFILE="$HOME/.bash_profile" # on Macs
# if ~/.bash_profile has not been defined, create it:
if [ ! -f "$BASHFILE" ]; then # NOT found:
fancy_echo "Creating blank \"${BASHFILE}\" ..." >>$LOGFILE
touch "$BASHFILE"
echo "PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" >>"$BASHFILE"
# El Capitan no longer allows modifications to /usr/bin, and /usr/local/bin is preferred over /usr/bin, by default.
else
LINES=$(wc -l < "${BASHFILE}")
fancy_echo "\"${BASHFILE}\" already created with $LINES lines." >>$LOGFILE
echo "Backing up file $BASHFILE to $BASHFILE-$LOG_DATETIME.bak ..." >>$LOGFILE
cp "$BASHFILE" "$BASHFILE-$LOG_DATETIME.bak"
fi
function BASHFILE_EXPORT() {
# example: BASHFILE_EXPORT "gitup" "open -a /Applications/GitUp.app"
name=$1
value=$2
if grep -q "export $name=" "$BASHFILE" ; then
fancy_echo "$name alias already in $BASHFILE" >>$LOGFILE
else
fancy_echo "Adding $name in $BASHFILE..."
# Do it now:
"export $name=$value"
# For after a Terminal is started:
echo "export $name='$value'" >>"$BASHFILE"
fi
}
######### bash completion:
# Because of the shebang, bash v4 is expected.
fancy_echo "$(bash --version | grep 'bash')" >>$LOGFILE
# See https://kubernetes.io/docs/tasks/tools/install-kubectl/#on-macos-using-bash
# Also see https://github.com/barryclark/bashstrap
# TODO: Extract 4 from $BASH_VERSION
# GNU bash, version 4.4.19(1)-release (x86_64-apple-darwin17.3.0)
## or, if running Bash 4.1+
#brew install bash-completion@2
## If running Bash 3.2 included with macOS
#brew install bash-completion
# brew info atom >>$LOGFILE
# brew list atom >>$LOGFILE
###### Install homebrew using whatever Ruby is installed:
# Ruby comes with MacOS:
fancy_echo "Using Ruby that comes with MacOS:" >>$LOGFILE
ruby -v >>$LOGFILE # ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
# Set the permissions that Brew expects
# sudo chflags norestricted /usr/local && sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local
#Mandatory:
if command_exists brew ; then
fancy_echo "Installing homebrew using Ruby..." >>$LOGFILE
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask
else
# Upgrade if run-time attribute contains "upgrade":
if [[ "${RUNTYPE,,}" == *"upgrade"* ]]; then
fancy_echo "Brew upgrading ..." >>$LOGFILE
brew --version
# brew upgrade # upgrades all modules.
fi
fi
#brew --version
fancy_echo "$(brew --version)" >>$LOGFILE
# Homebrew 1.5.12
# Homebrew/homebrew-core (git revision 9a81e; last commit 2018-03-22)
#echo "# Homebrew" >> ~/.bash_profile
#echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile
#brew tap caskroom/cask
# Casks are GUI program installers defined in https://github.com/caskroom/homebrew-cask/tree/master/Casks
# brew cask installs GUI apps (see https://caskroom.github.io/)
export HOMEBREW_CASK_OPTS="--appdir=/Applications"
brew analytics off # see https://github.com/Homebrew/brew/blob/master/docs/Analytics.md
function BREW_INSTALL() {
# Example call: BREW_INSTALL "GIT_CLIENTS" "git" "git --version"
local category="$1" # sample: "DATA_TOOLS"
local package="$2" # sample: "mysql"
local versions="$3" # sample: "brew"
fancy_echo "BREW_INSTALL $category $package ..." >>$LOGFILE
#if ! command -v "$package" >/dev/null; then
VER="$(brew info $package | grep "$package:")"
if [[ "$VER" != *"$package"* ]]; then
fancy_echo "$category $package installing ..." >>$LOGFILE
brew install "$package"
# brew info "$package" >>$LOGFILE
# brew list "$package" >>$LOGFILE
else
if [[ "${RUNTYPE,,}" == *"upgrade"* ]]; then
# $package -v
fancy_echo "$category $package upgrading ..." >>$LOGFILE
brew upgrade $package
elif [[ "${RUNTYPE,,}" == *"remove"* ]]; then
fancy_echo "$category $package removing ..." >>$LOGFILE
brew uninstall --force $package
fi
fi
if [[ $versions = *"brew"* ]]; then
echo "BREW_INSTALL $(brew info $package | grep "$package:")" >>$LOGFILE
#elif [[ -z "${versions// }" ]]; then #it's blank
# "$($package --version)" >>$LOGFILE
elif [[ $versions = "version" ]]; then
echo "BREW_INSTALL $($package version)" >>$LOGFILE
#else
# echo "BREW_INSTALL $($versions)" >>$LOGFILE
fi
}
function BREW_CASK_INSTALL() {
# Example: BREW_CASK_INSTALL "EDITORS" "webstorm" "Webstorm"
local category="$1"
local package="$2"
local appname="$3"
if [ ! -d "/Applications/$appname.app" ]; then
fancy_echo "$category $package installing ..."
brew cask install --appdir="/Applications" "$package"
else
if [[ "${RUNTYPE,,}" == *"upgrade"* ]]; then
# $package -v
fancy_echo "$category $package upgrading ..."
brew cask upgrade $package
elif [[ "${RUNTYPE,,}" == *"remove"* ]]; then
fancy_echo "$category $package removing ..." >>$LOGFILE
brew remove $package
#rm -rf "/Applications/$appname.app" #needed with uninstall
fi
fi
if ! command_exists $package ; then # define an alias to invoke from command line:
if grep -q "alias $package=" "$BASHFILE" ; then
fancy_echo "$category $package alias to $appname.app already in $BASHFILE" >>$LOGFILE
else
fancy_echo "$category $package alias to $appname.app in $BASHFILE ..."
echo "alias $package='open -a \"/Applications/$appname.app\"'" >>"$BASHFILE"
source $BASHFILE # Activate by running
fi
fi
echo "BREW_INSTALL $(brew cask info $package | grep "$package:")" >>$LOGFILE
}
######### Install git client to download the rest:
# TODO: Check for git command caz this is Mandatory:
if [[ "${GIT_CLIENTS,,}" == *"git"* ]]; then
BREW_INSTALL "GIT_TOOLS" "git" "git --version"
# git version 2.14.3 (Apple Git-98)
fi
function GITHUB_UPDATE() {
UPSTREAM="${1:-'@{u}'}"
LOCAL="$(git rev-parse @)"
REMOTE="$(git rev-parse "$UPSTREAM")"
BASE="$(git merge-base @ "$UPSTREAM")"
if [ $LOCAL = $REMOTE ]; then
echo "Up-to-date"
elif [ $LOCAL = $BASE ]; then
git fetch # instead of git pull
git log ..@{u} --oneline
#git reset --hard HEAD@{1} to go back and discard result of git pull if you don't like it.
git merge # Response: Already up to date.
elif [ $REMOTE = $BASE ]; then
git add . -A
git commit -m"GITHUB_UPDATE in $THISPGM"
git push
else
echo "Plese resolved diverged repo."
gitk master..upstream/master
#p4merge
fi
}
######### Download/clone GITHUB_REPO_URL repo:
# In order to keep secrets.sh out of the repo where it can be sent up to public GitHub:
SECRETSFILE="$HOME/secrets.sh"
GITHUB_PATH="https://github.com/wilsonmar/mac-setup.git"
REPO_PATH="$HOME/mac-setup"
if [ ! -f "$SECRETSFILE" ]; then # NOT found:
fancy_echo "$SECRETSFILE not found." >>$LOGFILE
if [ ! -d "$REPO_PATH" ]; then # NOT found:
fancy_echo "Cloning from $GITHUB_PATH ..." >>$LOGFILE
echo "to $REPO_PATH ..." >>$LOGFILE
git clone $GITHUB_PATH "$REPO_PATH"
cd $REPO_PATH
cp secrets.sh "$SECRETSFILE" # once only on init.
rm secrets.sh # so it's not edited by mistaks
else
cd $REPO_PATH
fancy_echo "Updating $REPO_PATH from $GIT" >>$LOGFILE
git pull
fi
fi
fancy_echo "At $(pwd)" >>$LOGFILE
pwd
######### Read and use secrets.sh file:
# If the file still contains defaults, it should not be used:
if grep -q "wilsonmar@gmail.com" "$SECRETSFILE" ; then # file contents not customized:
fancy_echo "Please edit file $SECRETSFILE with your own credentials. Aborting this run..."
exit # so script ends now
else
fancy_echo "Reading from $SECRETSFILE ..." >>$LOGFILE
# To preven fatal: '/Users/wilsonmar/secrets.sh' is outside repository
#pushd $HOME # not needed since SECRETSFILE var contains full path
# secrets.unlock.sh # prompt for password so can be read
chmod +x $SECRETSFILE
source "$SECRETSFILE" # to load contents into memory.
# TODO: run secrets.unlock.sh to lock it again
#popd
#git update-index --skip-worktree $SECRETSFILE
#fancy_echo "git ls-files -v|grep '^h' ::" >>$LOGFILE
#echo "$(git ls-files -v|grep '^S')" >>$LOGFILE
MAC_USERID=$(id -un 2>/dev/null || true) # example: wilsonmar
echo "SECRETSFILE=$SECRETSFILE ::" >>$LOGFILE
echo "RUNTYPE=$RUNTYPE ::" >>$LOGFILE
echo "GIT_NAME=$GIT_NAME">>$LOGFILE
echo "GIT_ID=$GIT_ID" >>$LOGFILE
echo "GIT_EMAIL=$GIT_EMAIL" >>$LOGFILE
echo "GIT_USERNAME=$GIT_USERNAME" >>$LOGFILE
echo "GITS_PATH=$GITS_PATH" >>$LOGFILE
echo "GITHUB_ACCOUNT=$GITHUB_ACCOUNT" >>$LOGFILE
echo "GITHUB_REPO=$GITHUB_REPO" >>$LOGFILE
# DO NOT echo $GITHUB_PASSWORD. Do not cat $SECRETFILE because it contains secrets.
echo "GIT_CLIENTS=$GIT_CLIENTS" >>$LOGFILE
echo "GIT_TOOLS=$GIT_TOOLS" >>$LOGFILE
echo "EDITORS=$EDITORS" >>$LOGFILE
echo "BROWSERS=$BROWSERS" >>$LOGFILE
echo "GIT_LANG=$GUI_LANG" >>$LOGFILE
echo "JAVA_TOOLS=$JAVA_TOOLS" >>$LOGFILE
echo "PYTHON_TOOLS=$PYTHON_TOOLS" >>$LOGFILE
echo "NODE_TOOLS=$NODE_TOOLS" >>$LOGFILE
echo "RUBY_TOOLS=$RUBY_TOOLS" >>$LOGFILE
echo "DATA_TOOLS=$DATA_TOOLS" >>$LOGFILE
echo "MARIADB_PASSWORD=$MARIADB_PASSWORD" >>$LOGFILE
echo "MONGODB_DATA_PATH=$MONGODB_DATA_PATH" >>$LOGFILE
echo "TEST_TOOLS=$TEST_TOOLS" >>$LOGFILE
echo "CLOUD_TOOLS=$CLOUD_TOOLS" >>$LOGFILE
echo "IRON_TOKEN=$IRON_TOKEN" >>$LOGFILE
echo "IRON_PROJECT_ID=$IRON_PROJECT_ID" >>$LOGFILE
# AWS_ACCESS_KEY_ID=""
# AWS_SECRET_ACCESS_KEY=""
# AWS_REGION="us-west-1"
# SAUCE_USERNAME=""
# SAUCE_ACCESS_KEY=""
echo "MON_TOOLS=$MON_TOOLS" >>$LOGFILE
echo "DOCKERHOSTS=$DOCKERHOSTS" >>$LOGFILE
echo "VIZ_TOOLS=$VIZ_TOOLS" >>$LOGFILE
echo "LOCALHOSTS=$LOCALHOSTS" >>$LOGFILE
echo "ELASTIC_PORT=$ELASTIC_PORT" >>$LOGFILE
echo "GRAFANA_PORT=$GRAFANA_PORT" >>$LOGFILE
echo "JEKYLL_PORT=$JEKYLL_PORT" >>$LOGFILE
echo "JENKINS_PORT=$JENKINS_PORT" >>$LOGFILE
echo "KIBANA_PORT=$KIBANA_PORT" >>$LOGFILE
echo "MYSQL_PORT=$MYSQL_PORT" >>$LOGFILE
echo "MEANJS_PORT=$MEANJS_PORT" >>$LOGFILE
echo "MINIKUBE_PORT=$MINKUBE_PORT" >>$LOGFILE
echo "NEO4J_PORT=$NEO4J_PORT" >>$LOGFILE
echo "NEXUS_PORT=$NEXUS_PORT" >>$LOGFILE
echo "NGINX_PORT=$NGINX_PORT" >>$LOGFILE
echo "PACT_PORT=$PACT_PORT" >>$LOGFILE
echo "POSTGRESQL_PORT=$POSTGRESQL_PORT" >>$LOGFILE
echo "PROMETHEUS_PORT=$PROMETHEUS_PORT" >>$LOGFILE
echo "REDIS_PORT=$REDIS_PORT" >>$LOGFILE
echo "SONAR_PORT=$SONAR_PORT" >>$LOGFILE
echo "TOMCAT_PORT=$TOMCAT_PORT" >>$LOGFILE
echo "TRYOUT=$TRYOUT" >>$LOGFILE
echo "TRYOUT_KEEP=$TRYOUT_KEEP" >>$LOGFILE
echo "COLAB_TOOLS=$COLAB_TOOLS" >>$LOGFILE
# TODO: Artifactory, Jira,
echo "MEDIA_TOOLS=$MEDIA_TOOLS" >>$LOGFILE
fi
GITS_PATH_INIT() {
newdir=$1
if [ ! -z "$GITS_PATH" ]; then # fall-back if not set in secrets.sh:
GITS_PATH="$HOME/gits" # the default
fi
if [ ! -d "$GITS_PATH" ]; then # no path, so create:
fancy_echo "GITS_PATH_INIT creating $GITS_PATH ..."
mkdir "$GITS_PATH"
fi
if [[ ! -z "${newdir// }" ]]; then #it's not blank
fancy_echo "GITS_PATH_INIT creating newdir=$newdir ..."
mkdir "$GITS_PATH/$newdir"
fi
}
######### MacOS hidden files configuration:
if [[ "${MAC_TOOLS,,}" == *"unhide"* ]]; then
fancy_echo "Configure OSX Finder to show hidden files too:" >>$LOGFILE
defaults write com.apple.finder AppleShowAllFiles YES
# also see dotfiles.
fi
######### MacOS maxfiles config:
echo "MAC_TOOLS=$MAC_TOOLS" >>$LOGFILE
if [[ "${MAC_TOOLS,,}" == *"maxfiles"* ]]; then
# CAUTION: This is not working yet.
FILE="/Library/LaunchDaemons/limit.maxfiles.plist"
if [ ! -f "$FILE" ]; then # NOT found, so add it
fancy_echo "Copying configs/ to $FILE ..."
sudo cp configs/limit.maxfiles.plist $FILE
#see http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/
sudo chmod 644 $FILE
fi
FILE="/Library/LaunchDaemons/limit.maxproc.plist"
if [ ! -f "$FILE" ]; then # NOT found, so add it
fancy_echo "Copying configs/ to $FILE ..."
sudo cp configs/limit.maxproc.plist $FILE
sudo chmod 644 $FILE
# https://apple.stackexchange.com/questions/168495/why-wont-kern-maxfiles-setting-in-etc-sysctl-conf-stick
fi
if grep -q "ulimit -n " "/etc/profile" ; then
fancy_echo "ulimit -n already in /etc/profile" >>$LOGFILE
else
fancy_echo "Concatenating ulimit 2048 to /etc/profile ..."
echo 'ulimit -n 2048' | sudo tee -a /etc/profile
fancy_echo "Now please reboot so the settings take. Exiting ..."
exit
#see http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/
fi
# Based on https://docs.microsoft.com/en-us/dotnet/core/macos-prerequisites?tabs=netcore2x
fancy_echo "launchctl limit ::" >>$LOGFILE
launchctl limit >>$LOGFILE # no sudo needed
OPEN_FILES=$(ulimit -n) # 256 default
fancy_echo "ulimit -a = $OPEN_FILES" >>$LOGFILE
# https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man3/sysctl.3.html
/usr/sbin/sysctl -a | grep files >>$LOGFILE
#kern.maxfiles: 49152
#kern.maxfilesperproc: 24576
#kern.num_files: 4692s
FILE="/etc/sysctl.conf"
if [ ! -f "$FILE" ]; then # NOT found, so add it
fancy_echo "Copying kern to $FILE ..."
echo "kern.maxfiles=49152" | sudo tee -a $FILE
echo "kern.maxfilesperproc=24576" | sudo tee -a $FILE
fi
fi
###### bash.profile locale settings missing in OS X Lion+:
if [[ "${MAC_TOOLS,,}" == *"locale"* ]]; then
# See https://stackoverflow.com/questions/7165108/in-os-x-lion-lang-is-not-set-to-utf-8-how-to-fix-it
# https://unix.stackexchange.com/questions/87745/what-does-lc-all-c-do
# LC_ALL forces applications to use the default language for output, and forces sorting to be bytewise.
if grep -q "LC_ALL" "$BASHFILE" ; then
fancy_echo "LC_ALL Locale setting already in $BASHFILE" >>$LOGFILE
else
fancy_echo "Adding LC_ALL Locale in $BASHFILE..." >>$LOGFILE
echo "# Added by $0 ::" >>"$BASHFILE"
echo "export LC_ALL=en_US.utf-8" >>"$BASHFILE"
#export LANG="en_US.UTF-8"
#export LC_CTYPE="en_US.UTF-8"
# Run .bash_profile to have changes take, run $FILEPATH:
source "$BASHFILE"
fi
#locale
# LANG="en_US.UTF-8"
# LC_COLLATE="en_US.UTF-8"
# LC_CTYPE="en_US.utf-8"
# LC_MESSAGES="en_US.UTF-8"
# LC_MONETARY="en_US.UTF-8"
# LC_NUMERIC="en_US.UTF-8"
# LC_TIME="en_US.UTF-8"
# LC_ALL=
BASHFILE_EXPORT "ARCHFLAGS" "-arch x86_64"
fi
######### Mac tools:
# Replaced OS X commands with the GNU version:
if [[ "${MAC_TOOLS,,}" == *"coreutils"* ]]; then
# see https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
# Not a command in /usr/local/bin/coreutils
BREW_INSTALL "MAC_TOOLS" "coreutils" "brew"
# Warning: coreutils 8.29 is already installed and up-to-date
# To reinstall 8.29, run `brew reinstall coreutils`
# Warning: less 530 is already installed and up-to-date
# To reinstall 530, run `brew reinstall less`
# TDDO: add `$(brew --prefix coreutils)/libexec/gnubin` to `$PATH` of /usr/local/opt/coreutils/libexec/gnubin
# Install some other useful utilities like `sponge`.
# brew install moreutils
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, `g`-prefixed.
# brew install findutils
# more From https://gist.github.com/xuhdev/8b1b16fb802f6870729038ce3789568f
# https://github.com/mathiasbynens/dotfiles/blob/master/brew.sh
brew install less
else
fancy_echo "MAC_TOOLS coreutils not specified." >>$LOGFILE
fi
if [[ "${MAC_TOOLS,,}" == *"iterm2"* ]]; then
# https://www.iterm2.com/documentation.html
BREW_CASK_INSTALL "MAC_TOOLS" "iterm2" "iTerm"
BASHFILE_EXPORT "CLICOLOR" "1"
if [[ "${TRYOUT,,}" == *"iterm"* ]] || [[ "${TRYOUT,,}" == *"all"* ]]; then
fancy_echo "Starting iTerm ..." >>$LOGFILE
open -a "/Applications/iTerm.app"
fi
# http://sourabhbajaj.com/mac-setup/iTerm/README.html
# TODO: https://github.com/mbadolato/iTerm2-Color-Schemes/tree/master/schemes
else
fancy_echo "MAC_TOOLS iterm2 not specified." >>$LOGFILE
fi
if [[ "${MAC_TOOLS,,}" == *"mas"* ]]; then
# To manage apps purchased & installed using App Store on MacOS:
BREW_INSTALL "MAC_TOOLS" "mas" "mas version"
if [[ "${TRYOUT,,}" == *"mas"* ]] || [[ "${TRYOUT,,}" == *"all"* ]]; then
fancy_echo "TRYOUT: mas listing apps added via App Store ..." >>$LOGFILE
mas list >>$LOGFILE
fi
else
fancy_echo "MAC_TOOLS mas not specified." >>$LOGFILE
fi
if [[ "${MAC_TOOLS,,}" == *"ansible"* ]]; then
# To install programs. See http://wilsonmar.github.io/ansible/
BREW_INSTALL "MAC_TOOLS" "ansible" "ansible -v"
else
fancy_echo "MAC_TOOLS ansible not specified." >>$LOGFILE
fi
if [[ "${MAC_TOOLS,,}" == *"1Password"* ]]; then
# See https://1password.com/ to store secrets on laptops securely.
if [ ! -d "/Applications/1Password 6.app" ]; then
#if ! command -v 1Password >/dev/null; then # /usr/local/bin/1Password
fancy_echo "Installing MAC_TOOLS 1Password - password needed ..."
brew cask install --appdir="/Applications" 1Password
else
if [[ "${RUNTYPE,,}" == *"upgrade"* ]]; then
# 1Password -v
fancy_echo "Upgrading MAC_TOOLS 1Password ..."
brew cask upgrade 1Password
fi
fi
#echo -e "$(1Password -v)" >>$LOGFILE # 1Password v6.0.0-beta.7
else
fancy_echo "MAC_TOOLS 1password not specified." >>$LOGFILE
fi
if [[ "${MAC_TOOLS,,}" == *"powershell"* ]]; then
# https://docs.microsoft.com/en-us/powershell/scripting/powershell-scripting?view=powershell-6
# https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-powershell-core-on-macos-and-linux?view=powershell-6#macos-1012
BREW_CASK_INSTALL "MAC_TOOLS" "powershell" "PowerShell"
# PowerShell v6.0.2
# From https://github.com/PowerShell/PowerShell
if [[ "${TRYOUT,,}" == *"powershell"* ]] || [[ "${TRYOUT,,}" == *"all"* ]]; then
fancy_echo "MAC_TOOLS powershell verify ..." >>$LOGFILE
{ echo '$psversiontable';
echo 'Get-ExecutionPolicy -List | Format-Table -AutoSize';
echo 'exit';
} | pwsh &
fi
else
fancy_echo "MAC_TOOLS powershell not specified." >>$LOGFILE
fi
if [[ "${MAC_TOOLS,,}" == *"alfred"* ]]; then
# https://www.alfredapp.com/ multi-function utility
# TODO: Get version 3 $(ls -dt /Applications/Alfred*|head -1)
BREW_CASK_INSTALL "MAC_TOOLS" "alfred" "Alfred 3"
if [[ "${TRYOUT,,}" == *"alfred"* ]] || [[ "${TRYOUT,,}" == *"all"* ]]; then
fancy_echo "Starting alfred ..." >>$LOGFILE
open -a "/Applications/alfred 3.app"
fi
# Buy the $19 https://www.alfredapp.com/powerpack/
else
fancy_echo "MAC_TOOLS Alfred not specified." >>$LOGFILE
fi
if [[ "${MAC_TOOLS,,}" == *"vmware-fusion"* ]]; then
BREW_CASK_INSTALL "MAC_TOOLS" "vmware-fusion" "VMware Fusion"
if [[ "${TRYOUT,,}" == *"vmware-fusion"* ]] || [[ "${TRYOUT,,}" == *"all"* ]]; then
fancy_echo "MAC_TOOLS vmware-fusion starting ..." >>$LOGFILE
open -a "/Applications/VMware Fusion.app"
fi
else
fancy_echo "MAC_TOOLS vmware-fusion not specified." >>$LOGFILE
fi
if [[ "${MAC_TOOLS,,}" == *"others"* ]]; then
echo "Installing MAC_TOOLS=others ...";
# brew cask install --appdir="/Applications" monolingual # remove unneeded osx lang files https://ingmarstein.github.io/Monolingual/
# brew cask install --appdir="/Applications" vmware-fusion # run Windows
# brew install google-drive
# brew install dropbox
# brew install box
# brew install amazon
# brew cask install --appdir="/Applications" charles # proxy
# brew cask install --appdir="/Applications" xtrafinder
# brew cask install --appdir="/Applications" sizeup # $12.99 resize windows http://www.irradiatedsoftware.com/sizeup/
# brew cask install --appdir="/Applications" bartender # manage icons at top launch bar
# brew cask install --appdir="/Applications" duet
# brew cask install --appdir="/Applications" logitech-harmony # multi-controller of TVs etc
# brew cask install --appdir="/Applications" cheatsheet # hold ⌘ gives you all the shortcuts you can use with the active app.
# brew cask install --appdir="/Applications" steam
# brew cask install --appdir="/Applications" fritzing
# brew cask install --appdir="/Applications" nosleep
# brew cask install --appdir="/Applications" balsamiq-mockups # for designing website forms
# brew cask install --appdir="/Applications" smartsynchronize
# brew cask install --appdir="/Applications" toggldesktop
# brew cask install --appdir="/Applications" xmind
# brew install jsdoc3
# brew cask install --appdir="/Applications" appcleaner
# brew cask install --appdir="/Applications" qlcolorcode
# brew cask install --appdir="/Applications" qlstephen
# brew cask install --appdir="/Applications" qlmarkdown
# brew cask install --appdir="/Applications" quicklook-json
# brew cask install --appdir="/Applications" quicklook-csv
# brew cask install --appdir="/Applications" betterzipql
# brew cask install --appdir="/Applications" asepsis
# brew cask install --appdir="/Applications" cheatsheet
# http://almworks.com/jiraclient/download.html
# brew cask install --appdir="/Applications" bluestacks # to emulate Android phone
fi
######### ~/.gitconfig initial settings:
GITCONFIG=$HOME/.gitconfig # file
if [ ! -f "$GITCONFIG" ]; then
fancy_echo "$GITCONFIG! file not found."
else
fancy_echo "Backing up $GITCONFIG-$LOG_DATETIME.bak ..." >>$LOGFILE
cp "$GITCONFIG" "$GITCONFIG-$LOG_DATETIME.bak"
fi
######### Git functions:
# Based on https://gist.github.com/dciccale/5560837
# Usage: GIT_BRANCH=$(parse_git_branch)$(parse_git_hash) && echo ${GIT_BRANCH}
# Check if branch has something pending:
function git_parse_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*"
}
# Get the current git branch (using git_parse_dirty):
function git_parse_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(git_parse_dirty)/"
}
# Get last commit hash prepended with @ (i.e. @8a323d0):
function git_parse_hash() {
git rev-parse --short HEAD 2> /dev/null | sed "s/\(.*\)/@\1/"
}
######### Language function definitions:
# Add function to read in string and email, and return a KEY found for that email.
# GPG_MAP_MAIL2KEY associates the key and email in an array
function GPG_MAP_MAIL2KEY() {
KEY_ARRAY=($(echo "$str" | awk -F'sec rsa2048/|2018* [SC]' '{print $2}' | awk '{print $1}'))
# Remove trailing blank: KEY="$(echo -e "${str}" | sed -e 's/[[:space:]]*$//')"
MAIL_ARRAY=($(echo "$str" | awk -F'<|>' '{print $2}'))
#Test if the array count of the emails and the keys are the same to avoid conflicts
if [ ${#KEY_ARRAY[@]} == ${#MAIL_ARRAY[@]} ]; then
declare -A KEY_MAIL_ARRAY=()
for i in "${!KEY_ARRAY[@]}"
do
KEY_MAIL_ARRAY[${MAIL_ARRAY[$i]}]=${KEY_ARRAY[$i]}
done
#Return key matching email passed into function
echo "${KEY_MAIL_ARRAY[$1]}"
else
#exit from script if array count of emails and keys are not the same
exit 1 && fancy_echo "Email count and Key count do not match"
fi
}
function VIRTUALBOX_INSTALL() {
BREW_CASK_INSTALL "VIRTUALBOX_INSTALL" "virtualbox" "VirtualBox"
BREW_CASK_INSTALL "VIRTUALBOX_INSTALL" "vagrant-manager" "Vagrant Manager"
}
function PYTHON_INSTALL() {
# Python2 is a pre-requisite for git-cola & GCP installed below.
# Python3 is a pre-requisite for aws.
# Because there are two active versions of Pythong (2.7.4 and 3.6 now)...
# See https://docs.brew.sh/Homebrew-and-Python
# See https://docs.python-guide.org/en/latest/starting/install3/osx/
BREW_INSTALL "PYTHON_INSTALL" "python" "python --version"
# Python 2.7.14
# Not brew install pyenv # Python environment manager.
#brew linkapps python
# pip comes with brew install Python 2 >=2.7.9 or Python 3 >=3.4
fancy_echo "$(pip --version)" >>$LOGFILE
# pip 9.0.3 from /usr/local/lib/python2.7/site-packages (python 2.7)
# Define command python as going to version 2.7:
BASHFILE_EXPORT "python" "/usr/local/bin/python2.7"
# To prevent the older MacOS default python being seen first in PATH ...
if grep -q "/usr/local/opt/python/libexec/bin" "$BASHFILE" ; then
fancy_echo "Python PATH already in $BASHFILE" >>$LOGFILE
else
fancy_echo "Adding Python PATH in $BASHFILE..."
echo "export PATH=\"/usr/local/opt/python/libexec/bin:$PATH\"" >>"$BASHFILE"
fi
# Run .bash_profile to have changes take, run $FILEPATH:
source "$BASHFILE"
#echo "$PATH"
# TODO: Python add-ons
#brew install freetype # http://www.freetype.org to render fonts
#brew install openexr
#brew install freeimage
#brew install gmp
#fancy_echo "Installing other popular Python helper modules ..."
#pip install jupyter
#pip install numpy
#pip install scipy
#pip install matplotlib
#pip install ipython[all]
# There is also a Enthought Python Distribution -- www.enthought.com
}
function PYTHON3_INSTALL() {
fancy_echo "Installing Python3 is a pre-requisite for AWS-CLI"
# Because there are two active versions of Python (2.7.4 and 3.6 now)...
# See https://docs.brew.sh/Homebrew-and-Python
# See https://docs.python-guide.org/en/latest/starting/install3/osx/
BREW_INSTALL "PYTHON3_INSTALL" "python3" "python3 --version"
# Python 3.6.4
echo "$(pip3 --version)" >>$LOGFILE
# pip 9.0.3 from /usr/local/lib/python3.6/site-packages (python 3.6)
if ! python3 -c "import pytz">/dev/null 2>&1 ; then
fancy_echo "Installing utility import pytz ..."
python3 -m pip install pytz # in /usr/local/lib/python3.6/site-packages
fi
# To use anaconda, add the /usr/local/anaconda3/bin directory to your PATH environment
# variable, eg (for bash shell):
# export PATH=/usr/local/anaconda3/bin:"$PATH"
#brew doctor fails run here due to /usr/local/anaconda3/bin/curl-config, etc.
#Cask anaconda installs files under "/usr/local". The presence of such
#files can cause warnings when running "brew doctor", which is considered
#to be a bug in Homebrew-Cask.
# NOTE: To make "python" command reach Python3 instead of 2.7, per docs.python-guide.org/en/latest/starting/install3/osx/
# Put in PATH Python 3.6 bits at /usr/local/bin/ before Python 2.7 bits at /usr/bin/
# QUESTION: What is the MacOS equivalent to pipe every .py file to anaconda's python:
# assoc .py=Python.File
# ftype Python.File=C:\path\to\Anaconda\python.exe "%1" %*
}
function GROOVY_INSTALL() {
# See http://groovy-lang.org/install.html
BREW_INSTALL "GROOVY_INSTALL" "groovy" "groovy --version"
# Groovy Version: 2.4.14 JVM: 1.8.0_162 Vendor: Oracle Corporation OS: Mac OS X
BASHFILE_EXPORT "GROOVY_HOME" "/usr/local/opt/groovy/libexec"
if [[ "${TRYOUT,,}" == *"groovy"* ]] || [[ "${TRYOUT,,}" == *"all"* ]]; then
fancy_echo "TRYOUT = groovy = run a Groovy script :"
groovy tests/groovy_smoketest
fi
# https://stackoverflow.com/questions/41110256/how-do-i-tell-intellij-about-groovy-installed-with-brew-on-osx
}
function JAVA_INSTALL() {
# See https://wilsonmar.github.io/java-on-apple-mac-osx/
# and http://sourabhbajaj.com/mac-setup/Java/
if ! command_exists java ; then
# /usr/bin/java
fancy_echo "Installing Java, a pre-requisite for Selenium, JMeter, etc. ..."
# Don't rely on Oracle to install Java properly on your Mac.
brew tap caskroom/versions
brew cask install --appdir="/Applications" java8
# CAUTION: A specific version of JVM needs to be specified because code that use it need to be upgraded.
fi
# TODO: Fix
TEMP=$(java -version | grep "java version") #| cut -d'=' -f 2 ) # | awk -F= '{ print $2 }'
JAVA_VERSION=${TEMP#*=};
echo "JAVA_VERSION=$JAVA_VERSION"
export JAVA_VERSION=$(java -version)
echo "JAVA_VERSION=$JAVA_VERSION" >>$LOGFILE
# java version "1.8.0_144"
# Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
# Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
if [ ! -z ${JAVA_HOME+x} ]; then # variable has NOT been defined already.
JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
#echo "export JAVA_HOME=$(/usr/libexec/java_home -v 9)" >>$BASHFILE
# /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home is a directory
fi
echo "JAVA_INSTALL JAVA_HOME=$JAVA_HOME" >>$LOGFILE
# https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
if grep -q "JAVA_HOME=" "$BASHFILE" ; then
echo "JAVA_INSTALL JAVA_HOME=$JAVA_HOME" >>$LOGFILE
else
echo "export JAVA_HOME=$JAVA_HOME" >>$BASHFILE
# /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
# echo "export IDEA_JDK=$(/usr/libexec/java_home -v $JAVA_VERSION)" >>$BASHFILE
# echo "export RUBYMINE_JDK=$(/usr/libexec/java_home -v $JAVA_VERSION)" >>$BASHFILE
source $BASHFILE
fi
# TODO: https://github.com/alexkaratarakis/gitattributes/blob/master/Java.gitattributes
}
function SCALA_INSTALL() {
# See http://scala-lang.org/install.html and http://sourabhbajaj.com/mac-setup/Scala/README.html
# There's also brew scala@2.10 scala@2.11
BREW_INSTALL "SCALA_INSTALL" "scala" "-version"
# Scala code runner version 2.12.5 -- Copyright 2002-2018, LAMP/EPFL and Lightbend, Inc.
BASHFILE_EXPORT "SCALA_HOME" "/usr/local/opt/scala/libexec"
# echo '-J-XX:+CMSClassUnloadingEnabled' >> /usr/local/etc/sbtopts
# echo '-J-Xmx2G' >> /usr/local/etc/sbtopts
# within Eclipse > Help → Install New Software..., add the Add... button in the dialog.
# To use with IntelliJ, set the Scala home to: /usr/local/opt/scala/idea
BREW_INSTALL "SCALA_INSTALL" "sbt" "brew"
#echo -e "sbt : $(sbt -version)" >>$LOGFILE
# Getting org.scala-sbt sbt 1.1.4 (this may take some time)...
if [[ "${TRYOUT,,}" == *"scala"* ]] || [[ "${TRYOUT,,}" == *"all"* ]]; then
fancy_echo "TRYOUT = run program HelloWorld.scala :"
scala tests/HelloWorld.scala
fi
# https://stackoverflow.com/questions/41110256/how-do-i-tell-intellij-about-scala-installed-with-brew-on-osx
}
function NODE_INSTALL() {
fancy_echo "In function NODE_INSTALL ..." >>$LOGFILE
# See https://wilsonmar.github.io/node-starter/
# http://treehouse.github.io/installation-guides/mac/node-mac.html
# We begin with NVM to install Node versions: https://www.airpair.com/javascript/node-js-tutorial
# in order to have several diffent versions of node installed simultaneously.
# See https://github.com/creationix/nvm
BASHFILE_EXPORT "NVM_DIR" "$HOME/.nvm"
if [ ! -d "$HOME/.nvm" ]; then
fancy_echo "Making $HOME/.nvm folder ..."
mkdir $HOME/.nvm
fi
BREW_INSTALL "NODE_INSTALL" "nvm" "" # node version manager
# 0.33.8
echo "npx -v : $(npx -v) " # 9.7.1 https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b
if ! command_exists node ; then
fancy_echo "Installing node using nvm"
nvm install node # use nvm to install the latest version of node.
# v9.10.1...
nvm install --lts # lastest Long Term Support version # v8.11.1...
# nvm install 8.9.4 # install a specific version
else
if [[ "${RUNTYPE,,}" == *"upgrade"* ]]; then
fancy_echo "node upgrading ..."
# nvm i nvm # instead of brew upgrade node
fi
fi
node --version >>$LOGFILE
# Run with latest Long Term Stable version:
# nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local/Cellar/nvm/0.33.8/versions/node/v9.10.1"
# a) Run with older Long Term Stable version:
# nvm run 8.11.1 --version
nvm use --lts >>$LOGFILE # (npm v5.6.0)
RESPONSE=$(nvm use --delete-prefix v8.11.1)
# b) Run with current newest version:
#RESPONSE=$(nvm use --delete-prefix v9.10.1)
fancy_echo "RESPONSE=$RESPONSE"
# node --version # v8.11.1 or v9.10.1
npm --version >>$LOzzGFILE
#echo -e "\n npm list -g --depth=1 --long" >>$LOGFILE
#echo -e "$(npm list -g --depth=1)" >>$LOGFILE
# v8.11.1
# v9.10.1
# node -> stable (-> v9.10.1) (default)
# stable -> 9.10 (-> v9.10.1) (default)
# iojs -> N/A (default)
# lts/* -> lts/carbon (-> v8.11.1)
# lts/argon -> v4.9.1 (-> N/A)
# lts/boron -> v6.14.1 (-> N/A)
# lts/carbon -> v8.11.1
# npm start
# See https://github.com/creationix/howtonode.org by Tim Caswell
# Look in folder node-test1
# $NVM_HOME
# $NODE_ENV
}
function GO_INSTALL() {
BREW_INSTALL "GO_INSTALL" "go" "version"
BASHFILE_EXPORT "GOPATH" "$HOME/golang"