-
Notifications
You must be signed in to change notification settings - Fork 6
/
macos_update.sh
executable file
·122 lines (99 loc) · 3.18 KB
/
macos_update.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
#!/bin/zsh
# To execute run:
#
# zsh macos_update.sh
#
# To source and then use individual update-* functions
# first comment out the command at the bottom of the file
# and run:
#
# source ./macos_update.sh
#
# If you want to use this command often copy it to directory
# that you have in PATH (check with `echo $PATH`) like this:
#
# USER_SCRIPTS="${HOME}/.local/bin" # change this
# cp ./macos_update.sh $USER_SCRIPTS/macos_update
# chmod +x $USER_SCRIPTS/macos_update
#
# and now you can call the script any time :)
# Text Color Variables
GREEN='\033[32m' # Green
CLEAR='\033[0m' # Clear color and formatting
update-brew() {
if ! which brew &>/dev/null; then return; fi
echo -e "${GREEN}Updating Brew Formula's${CLEAR}"
brew update
brew upgrade
brew cleanup -s
echo -e "\n${GREEN}Updating Brew Casks${CLEAR}"
brew outdated --cask
brew upgrade --cask
brew cleanup -s
echo -e "\n${GREEN}Brew Diagnostics${CLEAR}"
brew doctor
brew missing
}
update-atom() {
if ! which apm &>/dev/null; then return; fi
echo -e "\n${GREEN}Updating Atom${CLEAR}"
apm upgrade -c false
}
update-npm() {
if ! which npm &>/dev/null; then return; fi
echo -e "\n${GREEN}Updating npm Packages${CLEAR}"
npm update -g
}
update-gem() {
if ! which gem &>/dev/null; then return; fi
echo -e "\n${GREEN}Updating gems${CLEAR}"
gem update --user-install
gem cleanup --user-install
}
update-yarn() {
if ! which yarn &>/dev/null; then return; fi
echo -e "${GREEN}Updating Brew Formula's${CLEAR}"
yarn upgrade --latest
}
update-pip2() {
if ! which pip2 &>/dev/null; then return; fi
if ! which python2 &>/dev/null; then return; fi
echo -e "\n${GREEN}Updating Python 2.7.X pips${CLEAR}"
python2 -c "import pkg_resources; from subprocess import call; packages = [dist.project_name for dist in pkg_resources.working_set]; call('pip install --upgrade ' + ' '.join(packages), shell=True)"
#pip2 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip2 install -U
}
update-pip3() {
if ! which pip3 &>/dev/null; then return; fi
if ! which python3 &>/dev/null; then return; fi
echo -e "\n${GREEN}Updating Python 3.X pips${CLEAR}"
python3 -c "import pkg_resources; from subprocess import call; packages = [dist.project_name for dist in pkg_resources.working_set]; call('pip install --upgrade ' + ' '.join(packages), shell=True)"
#pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
}
update-app_store() {
if ! which mas &>/dev/null; then return; fi
echo -e "\n${GREEN}Updating App Store Applications${CLEAR}"
mas outdated
mas upgrade
}
update-macos() {
echo -e "\n${GREEN}Updating Mac OS${CLEAR}"
softwareupdate -i -a
}
update-office() {
echo -e "\n${GREEN}Updating MS-Office${CLEAR}"
/Library/Application\ Support/Microsoft/MAU2.0/Microsoft\ AutoUpdate.app/Contents/MacOS/msupdate --install
}
update-all() {
update-brew
update-atom
update-npm
update-gem
update-yarn
update-pip2
update-pip3
update-app_store
update-office
update-macos
}
# COMMENT OUT IF SOURCING
update-all