-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_packages
More file actions
executable file
·156 lines (112 loc) · 2.9 KB
/
Copy pathupdate_packages
File metadata and controls
executable file
·156 lines (112 loc) · 2.9 KB
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
#!/bin/bash
# Updates various packages.
set -o errexit
set -o nounset
set -o pipefail
set -o errtrace
ESSENTIAL_SCRIPTS_PATH="$HOME/essential-scripts"
pull_z() {
echo "Start pulling z ..."
local Z_DIR="z"
local Z_PATH="$ESSENTIAL_SCRIPTS_PATH/$Z_DIR"
if [[ -d "$Z_PATH" ]]; then
echo "Pulling z ..."
git -C "$Z_PATH" pull
printf "z pulled.\n\n"
else
echo "$Z_PATH does not exist."
exit 1
fi
printf "Finished pulling z.\n\n"
}
update_essential_scripts() {
echo "Start updating essential scripts ..."
if [[ -d "$ESSENTIAL_SCRIPTS_PATH" ]]; then
pull_z
else
echo "$ESSENTIAL_SCRIPTS_PATH does not exist."
exit 1
fi
printf "Finished updating essential scripts.\n\n"
}
update_homebrew_packages() {
echo "Start updating homebrew packages ..."
if [[ -x "$(command -v brew)" ]]; then
echo "Updating Homebrew's packages ..."
brew update
brew outdated
brew upgrade
printf "Homebrew's packages updated.\n\n"
else
echo "Homebrew is not installed or not executable."
exit 1
fi
printf "Finished updating homebrew packages\n\n"
}
update_omz() {
echo "Start updating omz ..."
local OMZ_BASH_FILE="oh-my-zsh.sh"
# $ZSH points to where OMZ is installed.
if [[ -f "$ZSH/$OMZ_BASH_FILE" ]]; then
echo "Updating OMZ ..."
"$ZSH/tools/upgrade.sh"
printf "OMZ updated.\n\n"
else
echo "OMZ is not installed."
exit 1
fi
printf "Finished updating omz.\n\n"
}
pull_powerlevel10k() {
echo "Start pulling powerlevel10k ..."
local POWERLEVEL10K_PATH="$ZSH/custom/themes/powerlevel10k"
if [[ -d "$POWERLEVEL10K_PATH" ]]; then
echo "Updating powerlevel10k ..."
git -C "$POWERLEVEL10K_PATH" pull
printf "powerlevel10k updated.\n\n"
else
echo "$POWERLEVEL10K_PATH does not exist."
exit 1
fi
printf "Finished pulling powerlevel10k.\n\n"
}
pull_omz_plugin() {
echo "Start pulling omz plugin: $1"
local PLUGIN_PATH="$ZSH/custom/plugins/$1"
if [[ -d "$PLUGIN_PATH" ]]; then
echo "Updating $1 ..."
git -C "$PLUGIN_PATH" pull
printf "omz plugin %s updated.\n\n" "$1"
else
echo "$PLUGIN_PATH does not exist."
exit 1
fi
printf "Finished updating omz plugin %s.\n\n" "$1"
}
update_omz_packages() {
echo "Start updating omz packages ..."
pull_powerlevel10k
pull_omz_plugin "zsh-autosuggestions"
pull_omz_plugin "zsh-syntax-highlighting"
printf "Finished updating omz packages.\n\n"
}
update_tpm_packages() {
echo "Start updating tpm packages ..."
if [[ -x "$(command -v tmux)" ]]; then
echo "Updating TPM's packages ..."
~/.tmux/plugins/tpm/bin/update_plugins all
printf "TPM's packages updated.\n\n"
else
echo "tmux is not installed or not executable."
exit 1
fi
printf "Finished updating tpm packages.\n\n"
}
main() {
update_essential_scripts
update_homebrew_packages
update_omz
update_omz_packages
update_tpm_packages
}
main