-
Notifications
You must be signed in to change notification settings - Fork 9
/
macsetup.sh
executable file
·5162 lines (4588 loc) · 105 KB
/
macsetup.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/bin/env zsh
source $HOME/.zshrc
#
# - run this script with "zsh macsetup.sh"
# - to erase correctly previous laptop disk, use the command: "diskutil secureErase 4 /dev/disk0"
#
#########################
# #
# Script Configurations #
# #
#########################
email="[email protected]"
workemail="[email protected]"
username="fharper"
#
# Load the colors function from ZSH
#
autoload colors; colors
#
# Pause the script until the user hit ENTER & display information to the user
#
# @param message for the user
#
function pausethescript {
echo $fg[yellow]"$1"$reset_color
echo "Press ENTER to continue the installation script"
read -r < /dev/tty
}
#
# Open file without knowing their exact file name.
#
# @param part of the file name
#
function openfilewithregex {
local file=$(findfilewithregex "$1")
open "${file}"
pausethescript "Wait for the $file installtion to end before continuing."
rm "${file}"
}
#
# Find a filename without knowing the exact file name
#
# @param part of the file name
#
function findfilewithregex {
echo $(find . -maxdepth 1 -execdir echo {} ';' | grep "$1")
}
#
# Detect if a GUI application has been installed
#
# @param the application name
#
# @return true if installed, false if not
#
function isAppInstalled {
if [[ $(osascript -e "id of application \"$1\"" 2>/dev/null) ]]; then
print $fg[green]"Skipped $fg[blue]$1$fg[green] already installed"$reset_color >&2
echo true
else
print $fg[blue]"Starting the installation of $1"$reset_color >&2
echo false
fi
}
#
# Install a Homebrew Keg, if not already installed
#
# @param the application name
#
function installkeg {
local alreadyInstalled=$(brew list "$1" 2>&1 | grep "No such keg")
if [[ -n "$alreadyInstalled" ]]; then
echo $fg[blue]"Starting the installation of $1"$reset_color
brew install "$1"
else
echo $fg[green]"Skipped $fg[blue]$1$fg[green] already installed"$reset_color
return 1
fi
}
function installfont {
local alreadyInstalled=$(brew list "$1" 2>&1 | grep "No such keg")
if [[ -n "$alreadyInstalled" ]]; then
echo $fg[blue]"Starting the installation of $1"$reset_color
brew install --cask "$1"
else
echo $fg[green]"Skipped $fg[blue]$1$fg[green] already installed"$reset_color
return 1
fi
}
#
# Detect if a Node.js package has been installed globally
#
# @param the package name
#
# @return true if installed, false if not
#
function isNodePackageInstalled {
if npm list -g $1 --depth=0 > /dev/null; then
echo true
else
echo false
fi
}
#
# Install the Node.js package globally, if not already installed
#
# @param Node.js package name
#
function installNodePackages {
if [[ "$(isNodePackageInstalled $1)" = "false" ]]; then
echo $fg[blue]"Starting the installation of $1"$reset_color
npm install -g "$1"
rehash
else
echo $fg[green]"Skipped $fg[blue]$1$fg[green] already installed"$reset_color
return 1
fi
}
#
# Install a Homebrew Cask, if not already installed
#
# @param the application name
#
function installcask {
if [[ "$(isAppInstalled $1)" = "false" ]]; then
brew install --cask $1
else
return 1
fi
}
#
# Install a App Store application, if not already installed
#
# @param the application ID
#
function installFromAppStore {
if [[ "$(isAppInstalled $1)" = "false" ]]; then
mas install "$2"
else
return 1
fi
}
#
# Obtain the full path of a GUI application
#
# @param the application name
#
# @return the full path of the application, empty if it does not exist
#
function getAppFullPath {
mdfind -name 'kMDItemFSName=="'"$1"'.app"' -onlyin /Applications -onlyin /System/Applications
}
#
# Detect if a CLI application has been installed
#
# @param the application name
#
# @return true if installed, false if not
#
function isCLAppInstalled {
if which "$1" > /dev/null; then
print $fg[green]"Skipped $fg[blue]$1$fg[green] already installed"$reset_color >&2
echo true
else
print $fg[blue]"Starting the installation of $1"$reset_color >&2
echo false
fi
}
#
# Install a Python package, if not already installed
#
# @param the package name
#
function installPythonPackage {
local package=$(pip list | grep "$1")
if [[ -n "$package" ]]; then
echo $fg[green]"Skipped $fg[blue]$1$fg[green] already installed"$reset_color
else
echo $fg[blue]"Installing the Python package $1"$reset_color
pip install "$1"
fi
}
#
# Install a Python application, if not already installed
#
# @param the application name
#
function installPythonApp {
local package=$(pipx list | grep "$1")
if [[ -n "$package" ]]; then
echo $fg[green]"Skipped $fg[blue]$1$fg[green] already installed"$reset_color
return 1
else
echo $fg[blue]"Installing the Python application $1"$reset_color
pipx install "$1"
fi
}
#
# Overwrite of the sudo command to give more context on why it's needed within the script
#
# @param the command to be executed with sudo
#
function sudo {
local needpass=$(/usr/bin/sudo -nv 2>&1 | grep "Input required")
#For whatever reason, chalk doesn't play well with $@,
# but is fine if the value is stored in another variable
local command=$@
if [[ "$needpass" ]]; then
echo $fg[blue]"The script need to use root (sudo) to run the $fg[green]$command$fg[blue] command"$reset_color
else
echo $fg[blue]"Using previously root (sudo) access to run the $fg[green]$command$fg[blue] command"$reset_color
fi
/usr/bin/sudo $@
}
#
# Use Mackup to restore a specific application settings
#
# @param the application name from Mackup
#
function restoreAppSettings {
echo "[storage]\nengine = icloud\n\n[applications_to_sync]\n$1" > $HOME/.mackup.cfg
mackup restore
echo "[storage]\nengine = icloud\n" > $HOME/.mackup.cfg
}
#
# Install the application from PKG inside of a DMG
#
# @param DMG filename
#
function installPKGfromDMG {
hdiutil attach "$1"
local volume="/Volumes/$(hdiutil info | grep /Volumes/ | sed 's@.*\/Volumes/@@' | tail -1)"
local pkg=$(/bin/ls "$volume" | grep .pkg)
installPKG "$volume/$pkg"
hdiutil detach "$volume"
rm "$1"
}
# Install the application from a PKG
#
# @param DMG filename
#
function installPKG {
sudo installer -pkg "$1" -target /
# Cannot delete the pkg from inside a volume (happen when run from installPKGfromDMG)
if [[ "$1" != "/Volumes/"* ]]; then
rm "$1"
fi
}
#
# Install the application from a DMG image when you just need to move the
# application into the macOS Applications folder
#
# @param DMG filename
# @param delete the DMG or not
#
function installDMG {
hdiutil attach "$1"
local volume="/Volumes/$(hdiutil info | grep /Volumes/ | sed 's@.*\/Volumes/@@')"
local app=$(/bin/ls "$volume" | grep .app)
mv "$volume/$app" /Applications
hdiutil detach "$volume"
if [[ "$2" = "true" ]]; then
rm "$1"
fi
}
#
# Reload .zshrc in the current shell
#
function reload {
source $HOME/.zshrc
}
#
# Create a csreq blob for a specific application
#
# @param app name
#
# @return csreq blob in hexadecimal
#
# Notes:
# - Process taken from https://stackoverflow.com/a/57259004/895232
#
function getCsreqBlob {
local app=$(getAppFullPath "$1")
# Get the requirement string from codesign
local req_str=$(codesign -d -r- "$app" 2>&1 | awk -F ' => ' '/designated/{print $2}')
echo "$req_str" | csreq -r- -b /tmp/csreq.bin
local hex_blob=$(xxd -p /tmp/csreq.bin | tr -d '\n')
rm /tmp/csreq.bin
echo "$hex_blob"
}
#
# Get the application bundle identifier
#
# @param app name
#
# @return the application bundle identifier
#
function getAppBundleIdentifier {
local app=$(getAppFullPath "$1")
mdls -name kMDItemCFBundleIdentifier -r "$app"
}
#
# Give Full Disk Access Permission for a specific application
#
# @param app name
#
function giveFullDiskAccessPermission {
updateTCC "kTCCServiceSystemPolicyAllFiles" "$1"
}
#
# Give Screen Recording Permission for a specific application
#
# @param app name
#
function giveScreenRecordingPermission {
updateTCC "kTCCServiceScreenCapture" "$1"
}
#
# Give Accessibility Permission for a specific application
#
# @param app name
#
function giveAccessibilityPermission {
updateTCC "kTCCServiceAccessibility" "$1"
}
#
# Update the access table in the TCC database with the new permission
#
# @param service for permission
# @param application identifier
# @param application csreq blob
#
# Notes:
# - More information on TCC at https://www.rainforestqa.com/blog/macos-tcc-db-deep-dive
#
function updateTCC {
local app_identifier=$(getAppBundleIdentifier "$2")
local app_csreq_blob=$(getCsreqBlob "$2")
# Columns:
# - service: the service for the permission (ex.: kTCCServiceSystemPolicyAllFiles for Full Disk Access permission)
# - client: app bundle identifier
# - client_type: 0 since it's the bundle identifier
# - auth_value: 2 for allowed
# - auth_reason: 3 user set
# - auth_version: always 1 for now
# - csreq: binary code signing requirement blob that the client must satisfy in order for access to be granted
# - policy_id: null, related to MDM
# - indirect_object_identifier_type: 0 since it's the bundle identifier
# - indirect_object_identifier: UNUSED since it's not needed for this permission
# - indirect_object_code_identity: same as csreq policy_id, so NULL
# - flags: not sure, always 0
# - last_modifified: last time entry was modified
local exist=$(sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "select count(service) from access where service = '$1' and client = '$app_identifier';")
if [[ exist ]]; then
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "update access SET auth_value=2 where service = '$1' and client = '$app_identifier';"
else
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "insert into access values('$1', '$app_identifier', 0, 2, 3, 1, '$app_csreq_blob', NULL, 0, 'UNUSED', NULL, 0, CAST(strftime('%s','now') AS INTEGER));"
fi
}
#
# Get the license key from 1Password & copy it to the clipboard
#
# @param the application we want the license key
#
function getLicense {
op item get "$1" --fields label="license key" | pbcopy
pausethescript "Add the license key from the clipboard to $1 before continuing"
}
#
# Get the license file from 1Password & open it
#
# @param the application we want the license key
# @param the filename of the license (will automate that when 1Password let you get the document file name)
#
function getLicenseFile {
op document get "$1" --output="$2"
open "$2"
pausethescript "Wait for $1 license to be added properly"
rm "$2"
}
#
# Remove an application from the Dock, if it's there
#
# @param the application we want to remove
#
function removeAppFromDock {
if [[ $(dockutil --list | grep "$1") ]]; then
echo $fg[blue]"Removing $1 from the Dock. The Dock will flash, it's normal."$reset_color
dockutil --remove "$1" --allhomes
fi
}
#
# Confirm running or not the command
#
# @param the text for the confirmation
# @param the command to run if accepted
#
function confirm {
vared -p "$1 [y/N]: " -c ANSWER
if [[ "$ANSWER" = "Y" ]] || [[ "$ANSWER" = "y" ]] || [[ "$ANSWER" = "yes" ]] || [[ "$ANSWER" = "YES" ]]; then
eval $2
fi
}
#
# Remove a pre-installed application
#
# @param application name
#
function removeApp {
local app=$(getAppFullPath "$1")
if [[ "$app" ]]; then
echo $fg[blue]"Removing $1 from your computer."$reset_color
sudo rm -rf "$app"
fi
}
#
# Display the section information for the script section being run
#
# @param section name
#
function displaySection {
local length=${#1}+4
print "\n"
for (( i=1; i<=$length; i++ )); do
print -n "$fg[magenta]#";
done
print -n "\n#"
for (( i=1; i<=$length-2; i++ )); do
print -n " ";
done
print "#"
print "# $1 #"
print -n "#"
for (( i=1; i<=$length-2; i++ )); do
print -n " ";
done
print "#"
for (( i=1; i<=$length; i++ )); do
print -n "#";
done
print "\n$reset_color"
}
#
# Install a Rust application, if not already installed
#
# @param the application name
#
function installRustApp {
local package=$(cargo install --list | grep "$1")
if [[ -n "$package" ]]; then
echo $fg[green]"Skipped $fg[blue]$1$fg[green] already installed"$reset_color
return 1
else
echo $fg[blue]"Installing the Python application $1"$reset_color
cargo install "$1"
reload
fi
}
#
# Install asdf plugin, and a specific version of the plugin while setting it as the global version
#
# @param plugin name
# @param version of the plugin to instal
#
function installAsdfPlugin {
if [[ $(asdf current $1) ]]; then
echo $fg[green]"Skipped asdf plugin $fg[blue]$1$fg[green] already installed"$reset_color
return 1
else
echo $fg[blue]"Installing the asdf plugin $1 & its version $2"$reset_color
asdf plugin-add $1
asdf install $1 $2
asdf global $1 $2
reload
fi
}
#
# Install Go applications
#
# @param application name
# @param version of the application (default to latest)
#
function installGoApp {
if [[ "$(isCLAppInstalled $1)" = "true" ]]; then
echo $fg[green]"Skipped $fg[blue]$1$fg[green] already installed"$reset_color
return 1
else
version=$2
if [[ "$version" = "" ]]; then
version="latest"
fi
echo $fg[blue]"Installing the version $version of the Go application $1"$reset_color
go install "$1"@"$version"
asdf reshim golang
fi
}
#
# Get macOS codename (Monterey, Ventura, Sonoma...)
#
# @return macOS codename
#
function getmacOSCodename {
sed -nE '/SOFTWARE LICENSE AGREEMENT FOR/s/.*([A-Za-z]+ ){5}|\\$//gp' /System/Library/CoreServices/Setup\ Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf
}
############################
# #
# Utils to run this script #
# #
# (the order is important) #
# #
############################
displaySection "Utils to run this script"
#
# Rosetta2
#
# Run x86_64 app on arm64 chip
#
# https://developer.apple.com/documentation/apple_silicon/about_the_rosetta_translation_environment
#
# Notes
# - You may get a "Package Authoring Error" even if the installation worked (https://discussions.apple.com/thread/253780410)
# - Cannot be added to apps.yml for now as it doesn't manage custom installation check
#
if [[ -z $(pgrep oahd) ]]; then
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
fi
#
# Xcode Command Line Tools
#
# Command line XCode tools & the macOS SDK frameworks and headers
#
# https://developer.apple.com/xcode
#
# Notes
# - Cannot be added to apps.yml for now as it doesn't manage custom installation check
#
if [[ $(xcode-select -p 1> /dev/null; echo $?) -eq 2 ]]; then
xcode-select --install
pausethescript "Wait for the XCode Tools installation to finish before continuing."
fi
#
# Homebrew + homebrew-cask-versions + brew-cask-upgrade + Casks for Fonts
#
# macOS package manager
# Alternate versions of Homebrew Casks
# CLI for upgrading outdated Homebrew Casks
# Casks for Fonts
#
# https://github.com/Homebrew/brew
# https://github.com/Homebrew/homebrew-cask-versions
# https://github.com/buo/homebrew-cask-upgrade
# https://github.com/Homebrew/homebrew-cask-fonts
#
# Notes
# - Cannot be added to apps.yml for now as it doesn't manage custom installation
#
if [[ "$(isCLAppInstalled brew)" = "false" ]]; then
echo $fg[blue]"Starting the installation of Homebrew"$reset_color
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Needed once here since we didn't restore & source $HOME/.zshrc yet, but we need Homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
brew analytics off
brew tap homebrew/cask-versions
brew tap buo/cask-upgrade
brew tap homebrew/cask-fonts
fi
#
# Mackup
#
# Sync applications settings with any file sync services
#
# https://github.com/lra/mackup
#
# Notes: needed right after Homebrew so configurations files can be restored
#
installkeg mackup
#
# asdf
#
# Version manager with support for everything
#
# https://github.com/asdf-vm/asdf
#
# Notes
# - Needed before Python
#
# Help
# - To list all available versions for a language, use: asdf list all nodejs
# - To install a language version, use: asdf install nodejs 22.4.1
#
if [[ "$(isCLAppInstalled asdf)" = "false" ]]; then
installkeg asdf
reload
fi
#
# Python + PipX + Wheel + Pylint + pytest + Twine
#
# Python SDK
# Isolated Environments Pip alternative for app (not packages)
# Python wheel packaging tool
# Python linter
# Python tests framework
# Utilities for interacting with PyPI
#
# https://www.python.org
# https://github.com/pypa/pipx
# https://github.com/pypa/wheel
# https://github.com/PyCQA/pylint/
# https://github.com/pytest-dev/pytest
# https://github.com/pypa/twine/
#
# Notes
# - Needed before lastversion
#
if [[ ! $(asdf current python) ]]; then
installAsdfPlugin python 3.11.2
installkeg pipx
pipx ensurepath
installPythonPackage wheel
installPythonApp pylint
installPythonApp pytest
installPythonApp twine
fi
#
# lastversion
#
# CLI to get latest GitHub Repo Release assets URL
#
# https://github.com/dvershinin/lastversion
#
# Notes
# - Needed before Dockutil
#
installPythonApp lastversion
#
# macports-base
#
# MacPorts CLI
#
# https://github.com/macports/macports-base/
#
# Notes:
# - Needed after lastversion install
# - Cannot be added to apps.yml for now as it doesn't manage custom installation check
#
if [[ "$(isCLAppInstalled port)" = "false" ]]; then
curl -L "$(lastversion macports/macports-base --assets --filter $(getmacOSCodename)\.pkg$)" --output macports.pkg
installPKG macports.pkg
fi
#
# Dockutil
#
# Utility to manage macOS Dock items
#
# https://github.com/kcrawford/dockutil
#
# Notes
# - Homebrew version not updated
# - Needed before iTerm2
# - Cannot be added to apps.yml for now as it doesn't manage custom installation check
#
if [[ "$(isCLAppInstalled dockutil)" = "false" ]]; then
echo $fg[blue]"Starting the installation of Dockutil"$reset_color
curl -L "$(lastversion kcrawford/dockutil --assets)" --output dockutil.pkg
sudo installer -pkg dockutil.pkg -target /
rm dockutil.pkg
fi
#
# iTerm2
# iTerm2 Shell Integration
#
# Terminal replacement
#
# https://github.com/gnachman/iTerm2
# https://iterm2.com/documentation-shell-integration.html
#
if [[ "$(isAppInstalled iTerm)" = "false" ]]; then
installcask iterm2
giveFullDiskAccessPermission iTerm
dockutil --add /Applications/iTerm.app/ --allhomes
curl -L https://iterm2.com/shell_integration/install_shell_integration.sh | bash
open -a iTerm
echo $fg[yellow]"You can now close the Terminal app, and continue on iTerm"$reset_color
exit
fi
#
# Git
#
# File versioning
#
# https://github.com/git/git
#
# Notes: needed before Oh My Zsh as .zhrc have some git usage in it
#
if [[brew list git 2>&1 | grep "No such keg"]]; then
installkeg git
git config --replace-all --global advice.addIgnoredFile false
git config --replace-all --global advice.addEmptyPathspec false
git config --replace-all --global advice.skippedCherryPicks false
git config --replace-all --global clean.requireForce false
git config --replace-all --global core.hooksPath $HOME/.git/hooks
git config --replace-all --global core.ignorecase false
git config --replace-all --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
git config --replace-all --global credential.username $email
git config --replace-all --global diff.tool vscode
git config --replace-all --global difftool.prompt false
git config --replace-all --global difftool.vscode.cmd "code --diff --wait $LOCAL $REMOTE"
git config --replace-all --global fetch.prune true
git config --replace-all --global help.autocorrect 10
git config --replace-all --global http.postBuffer 2097152000
git config --replace-all --global init.defaultBranch main
git config --replace-all --global interactive.diffFilter "diff-so-fancy --patch"
git config --replace-all --global pull.rebase true
git config --replace-all --global push.autoSetupRemote true
git config --replace-all --global push.default current
git config --replace-all --global push.followTags true
git config --replace-all --global rebase.autoStash true
git config --replace-all --global user.email $email
git config --replace-all --global user.name "Frédéric Harper"
fi
#
# GitPython
#
# Python library for Git
#
# https://github.com/gitpython-developers/GitPython
#
# Notes: needed for the file size pre-commit hook
#
installPythonPackage gitpython
#
# Oh My Zsh
#
# Zsh configurations framework & management
#
# https://github.com/ohmyzsh/ohmyzsh
#
if [[ "$(isCLAppInstalled omz)" = "false" ]]; then
echo $fg[blue]"Starting the installation of Oh My Zsh"$reset_color
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# Restoring here since OMZ backup $HOME/.zshrc to $HOME/.zshrc.pre-oh-my-zsh
restoreAppSettings zsh
rm $HOME/.zshrc.pre-oh-my-zsh
reload
fi
#
# starship
#
# The minimal, blazing-fast, and infinitely customizable prompt for any shell
#
# https://github.com/starship/starship
#
# Notes: need to be after Oh My Zsh
#
if [[ ! -d "/opt/homebrew/opt/spaceship/" ]]; then
instalkeg starship
reload
fi
#
# Restore different files with Mackup (not app specifics)
#
if [[ ! -L "$HOME/.zshrc" ]]; then
restoreAppSettings files
restoreAppSettings vim
reload
fi
#
# mas-cli
#
# Unofficial macOS App Store CLI
#
# https://github.com/mas-cli/mas
#
# Notes: Need to install before Xcode
#
if [[ "$(isCLAppInstalled mas)" = "false" ]]; then
installkeg mas
open -a "App Store"
pausethescript "Sign in into the App Store before continuing"
fi
#
# Xcode
#
# macOS/iOS Swift/Ojective-C IDE
#
# https://developer.apple.com/xcode
#
# Notes: need to install before defbro
#
if [[ "$(isAppInstalled Xcode)" = "false" ]]; then
installFromAppStore XCode 497799835
sudo xcodebuild -license accept
xcodebuild -runFirstLaunch
restoreAppSettings Xcode
fi
#
# defbro
#
# CLI to change the default browser
#
# https://github.com/jwbargsten/defbro
#
if [[ "$(isCLAppInstalled defbro)" = "false" ]]; then
brew tap jwbargsten/misc
installkeg defbro
fi
#
# Duti
#
# Utility to set default applications for document types (file extensions)
#
# https://github.com/moretension/duti
#
installkeg duti
#
# jq
#
# Command-line JSON processor
#
# https://github.com/stedolan/jq
#
# JSON processor
#
installkeg jq
#
# icalBuddy
#
# Command-line utility for printing events and tasks from the OS X calendar database
#
# https://github.com/ali-rantakari/icalBuddy
#
installkeg ical-buddy
#
# loginitems
#
# Utility to manage startup applications
#
# https://github.com/ojford/loginitems
#
if [[ "$(isCLAppInstalled loginitems)" = "false" ]]; then
brew tap OJFord/formulae
installkeg loginitems
fi
#
# mysides
#
# Finder sidebar tool
#
# https://github.com/mosen/mysides
#
installkeg mysides
#
# Node.js + npm CLI
#
# Node.js programming language SDK
# Node Package Manager CLI
#
# https://github.com/nodejs/node
# https://github.com/npm/cli
#
if [[ ! $(asdf current nodejs) ]]; then
installAsdfPlugin nodejs 19.6.0
20.5.0
npm i -g npm@latest
npm adduser
fi
#
# BZip2
#
# Data compressor
#
# https://sourceware.org/bzip2/
#
installkeg BZip2
#
# osXiconUtils
#
# Utilities for working with macOS icons
#
# https://github.com/sveinbjornt/osxiconutils
#
if [[ "$(isCLAppInstalled geticon)" = "false" ]]; then
echo $fg[blue]"Starting the installation of osXiconUtils"$reset_color
curl -L https://sveinbjorn.org/files/software/osxiconutils.zip --output osxiconutils.zip
unzip osxiconutils.zip
rm osxiconutils.zip
rm -rf __MACOSX #created by the unzip call
sudo chown $username:admin /usr/local/bin
mv bin/geticon /usr/local/bin/
mv bin/seticon /usr/local/bin/
rm -rf bin/
fi