-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·111 lines (92 loc) · 2.4 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
BLUE="\033[0;36m"
NORMAL="\033[0m"
DOTFILES_NAME='.dotfiles'
DOTFILES_GIT_URI='https://github.com/luismayta/dotfiles.git'
DOTFILES_GIT_BRANCH='main'
PATH_REPO="${HOME}/${DOTFILES_NAME}"
export PATH=${PATH}:/opt/homebrew/bin
function message::info {
printf "${BLUE}%s${NORMAL}\n" "[INFO]: ${1}"
}
function message::warning {
printf "${YELLOW}%s${NORMAL}\n" "[WARNING]: ${1}"
}
function message::success {
printf "${GREEN}%s${NORMAL}\n" "🧉 [SUCCESS]: ${1}"
}
function message::error {
printf "${RED}%s${NORMAL}\n" "😈 [ERROR]: ${1}"
}
function message::debug {
printf "${YELLOW}%s${NORMAL}\n" "😈 [DEBUG]: ${1}"
}
clone_repo() {
if [[ ! -e "${PATH_REPO}/.git" ]]; then
git clone --recursive -b "${DOTFILES_GIT_BRANCH}" "${DOTFILES_GIT_URI}" "$PATH_REPO"
ret="$?"
message::success "$1"
else
upgrade_repo "${APP_NAME}" "Successfully updated ${DOTFILES_NAME}"
fi
if [[ "$ret" -eq '0' ]] && [[ ! ${TRAVIS} = 'true' ]]; then
cd "${PATH_REPO}" || exit
make run
fi
}
############################ BASIC SETUP TOOLS
program_exists() {
local app=$1
local message="Need to install ${app}."
local ret='0'
type -p "${1}" >>/dev/null 2>&1 || { local ret='1'; }
# throw error on non-zero return value
if [[ ! "$ret" -eq '0' ]]; then
message::error "${message}"
exit
fi
}
function upgrade_repo() {
message::info "trying to update ${1}"
if [ "${1}" = "${DOTFILES_NAME}" ]; then
cd "${PATH_REPO}" || exit
git pull origin "${GIT_BRANCH}"
fi
ret="$?"
message::success "${2}"
}
# Mac Stuff -------------------------------------------------------------------
if [[ $(uname) == 'Darwin' ]]; then
if ! type -p brew >/dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew install zsh git rsync \
jq ag fd ripgrep cmake ksh
zsh --login
fi
# Archlinux Stuff
if type -p pacman >/dev/null; then
packages=(
git
go
npm
yarn
gcc
rsync
)
for package in "${packages[@]}"; do
sudo pacman -S --noconfirm "${package}"
done
npm install -g n
fi
for app in {zsh,git,rsync}; do
program_exists "${app}"
done
unset app
clone_repo "Successfully cloned ${DOTFILES_NAME}"
message::info "\nThanks for installing ${DOTFILES_NAME}."
message::info "© $(date +%Y) ${DOTFILES_NAME}"