-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
74 lines (61 loc) · 1.36 KB
/
install.sh
File metadata and controls
74 lines (61 loc) · 1.36 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
#!/bin/sh
if [ -n "`$SHELL -c 'echo $ZSH_VERSION'`" ]; then
# assume zsh
rc=~/.zshrc
sh="zsh"
elif [ -n "`$SHELL -c 'echo $BASH_VERSION'`" ]; then
# assume bash
rc=~/.bashrc
sh="bash"
fi
setup_color() {
# only use colors if connected to a terminal
if [ -t 1 ]; then
RED=$(printf '\033[31m')
GREEN=$(printf '\033[32m')
CYAN=$(printf '\033[36m')
RESET=$(printf '\033[m')
else
RED=""
GREEN=""
CYAN=""
RESET=""
fi
}
error() {
echo ${RED}"$@"${RESET} >&2
}
success() {
echo ${GREEN}"$@"${RESET} >&2
}
cyan() {
echo ${CYAN}"$@"${RESET} >&2
}
# tell the user what's going on
setup_color
cyan "Setting up exp"
# clone the project (uncomment the following for production)
cd ~/ || exit
rm -rf ".exp"
git clone --depth=1 "https://github.com/malcolmkiano/exp.git" ".exp"
cd - # go back to where we were before
echo
# local testing code (uncomment the following for local development)
# rm -rf ~/.exp
# mkdir ~/.exp
# cp -ar ./ ~/.exp
# sleep 1s
# install it in the corresponding shell
cyan "Installing exp"
chmod +x ~/.exp/exp.sh
cat >> $rc << EOT
alias exp='~/.exp/exp.sh'
EOT
echo
sleep 1s
# we're golden
success "Installation was successful. Your terminal settings have been reloaded."
echo
echo "To use: ${CYAN}exp ${GREEN}project-name${RESET} ${CYAN}'project description'${RESET} [-options]"
echo "To view help, run: ${CYAN}exp -h${RESET}"
exec "$sh"