forked from nelsonmestevao/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.sh
61 lines (53 loc) · 1.34 KB
/
helpers.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
#!/bin/bash
function echo_error() {
printf '\n\033[31mERROR:\033[0m %s\n' "$1"
}
function echo_warning() {
printf '\n\033[33mWARNING:\033[0m %s\n' "$1"
}
function echo_done() {
printf '\n\033[32mDONE:\033[0m %s\n' "$1"
}
function echo_info() {
printf '\n\033[36m%s\033[0m\n' "$1"
}
function _update() {
if [[ $1 != "system" ]]; then
echo_info "Updating system packages..."
sudo "$PKGMN" "$PKGU" "${PKGOPT[@]}"
else
echo_info "Updating ${1}..."
sudo "$PKGMN" "$PKGI" "$1"
fi
}
function _install() {
if [[ $1 == "core" ]]; then
for pkg in "${PKG[@]}"; do
echo_info "Installing ${pkg}..."
if ! [ -x "$(command -v rainbow)" ]; then
sudo "$PKGMN" "$PKGI" "$pkg" "${PKGOPT[@]}"
else
rainbow --red=error --yellow=warning sudo "$PKGMN" "$PKGI" "$pkg" "${PKGOPT[@]}"
fi
echo_done "${pkg} installed!"
done
elif [[ $1 == "aur" ]]; then
for aur in "${AUR[@]}"; do
echo_info "Installing ${aur}..."
yaourt -Sy "$aur" --needed --noconfirm
echo_done "${aur} installed!"
done
else
echo_info "Intalling ${1}..."
sudo "$PKGMN" "$PKGI" "$1"
fi
}
function _symlink() {
dirs=$(find . -maxdepth 1 -mindepth 1 -type d -not -name '.git' -print)
for dir in $dirs; do
echo "Installing ${dir}..."
cd "$dir" || exit
./install.sh
cd ..
done
}