-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
88 lines (66 loc) · 1.59 KB
/
install.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
#!/usr/bin/env bash
# shellcheck disable=SC2154
set -euo pipefail
esc="\033"
reset="${esc}[0m"
# 256 Colors Foreground
for color in {0..255}; do
declare "color${color}=${esc}[38;5;${color}m"
done
# 256 Colors Background
for bg in {0..255}; do
declare "bg${bg}=${esc}[48;5;${bg}m"
done
function print_help() {
echo
}
function die() {
local _ret="${2:-1}"
if [[ $_ret != 0 ]]; then
test "${_PRINT_HELP:-no}" = yes && print_help >&2
echo -e "$1" >&2
else
test "${_PRINT_HELP:-no}" = yes && print_help
echo -e "$1"
fi
exit "${_ret}"
}
function info() {
echo -e "\n${color14}==>${reset} $1 ℹ\n"
}
function step() {
echo -e "\n${color13}==>${reset} $1 👟\n"
}
function success() {
echo -e "\n${color2}==>${reset} $1 ✔\n"
}
function fail() {
die "\n${color1}==>${reset} $1 ❌\n" 1
}
#===================================================0
deps=(gzip chezmoi git wget curl tar lazygit fd rg nvim grep delta rbw unzip)
function check_dependencies() {
step "Checking dependencies..."
missing_commands=""
for dep in "${deps[@]}"; do
type -p "$dep" &>/dev/null || {
missing_commands+="$dep "
}
done
# Remove trailing space from missing_commands (if any)
missing_commands="${missing_commands% }"
if [ -n "$missing_commands" ]; then
fail "Could not find: $missing_commands\n Is it installed?" >&2
fi
info "OK!"
}
function bootstrap_dotfiles() {
step "Install dotfiles..."
chezmoi init latipun7 --apply
}
function main() {
check_dependencies
bootstrap_dotfiles
success "All done 👏\n Please restart your terminal 🎉"
}
main