-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate-dotfiles.sh
executable file
·63 lines (57 loc) · 1.53 KB
/
update-dotfiles.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
#!/usr/bin/env zsh
main() {
UPDATE=1
step "Checking for updates of dotfiles repository"
git -C $HOME/.dotfiles fetch &> /dev/null
if [ $(git -C $HOME/.dotfiles rev-parse HEAD) '==' $(git -C $HOME/.dotfiles rev-parse @{u}) ]; then
success "Already up to date"
UPDATE=0
if [[ "$1" = "--force" ]]; then
warning "Forcing update"
UPDATE=1
fi
fi
if [[ "$UPDATE" -eq 1 ]]; then
warning "Update needed"
step "Updating..."
git -C $HOME/.dotfiles pull | prependInfo # pull first, so the script is updated before executing
$HOME/.dotfiles/setup-mac-os.sh --update
fi
step "Update Homebrew"
update=$(brew update | head -n 1)
if [[ $update == "Already up-to-date." ]]; then
success "Already up to date"
else
echo $update | prependInfo
fi
step "Update Software installed via Homebrew"
if [[ $(brew outdated) ]]; then
warning "The following Software is outdated and will be updated:"
brew outdated -q | prependInfo
brew upgrade
else
success "Already up-to-date"
fi
step "Update tldr"
if tldr --update; then
success "Updated"
else
warning "Could not update tldr"
fi
}
function step() {
print -P "%F{blue}=> $1%f"
}
function warning() {
print -P "%F{yellow}==> $1%f"
}
function success() {
print -P "%F{green}==> $1%f"
}
function prependInfo() {
while read line;
do
print -P "%F{white}===> $line%f";
done;
}
main "$@"