-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·109 lines (92 loc) · 2.2 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
#!/usr/bin/env bash
COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;32m'
COLOR_NONE='\033[0m'
COLOR_YELLOW='\033[1;33m'
OS="$(uname)"
# Ensure homebrew is installed.
function ensure_homebrew() {
if test ! "$(command -v brew)"; then
echo "Homebrew is not installed. Installing."
# Run as a login shell (non-interactive) so that the script doesn't pause for user input
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash --login
fi
}
# Setup terminfo for tmux usage with italics support.
function setup_terminfo() {
tic -x "tmux/tmux.terminfo"
tic -x "tmux/xterm-256color-italic.terminfo"
}
function bootstrap() {
echo "Bootstrapping the system"
if [ "$OS" == "Darwin" ]; then
echo "Brewing Everything..."
ensure_homebrew
brew bundle
echo "Configuring terminfo"
setup_terminfo
echo "Updating OSX settings..."
bash scripts/osx.sh
fi
}
function link() {
if [ "$OS" == "Darwin" ]; then
if [ ! $(type -p stow) ]; then
echo "stow is not installed. Installing."
ensure_homebrew
brew install stow
fi
echo "Linking osx dotfiles..."
bash scripts/run_stow.sh osx
echo "Configuring terminfo"
setup_terminfo
elif [ "$OS" == "Linux" ]; then
echo "Linking linux dotfiles..."
bash scripts/run_stow.sh linux
else
echo "Unsupported OS type!"
exit 1
fi
}
function unlink() {
echo "Removing all dotfiles..."
bash scripts/run_stow.sh all unlink
}
function usage() {
cat<<EOD
Usage:
bootstrap [options] -- Install software packages
link [options] -- Link all dotfiles
unlink [options] -- Remove all dotfile symlinks
all [options] -- Install software and link dotfiles
EOD
exit 1
}
if [[ "$#" == "0" ]]; then
usage
fi
command="$1"
if [[ "$command" == "" ]]; then
echo "first argument must be a command"
usage
fi
case "$command" in
all)
bootstrap
link
;;
link)
link
;;
bootstrap)
bootstrap
;;
unlink)
unlink
;;
*)
usage
;;
esac
echo -e "${COLOR_GREEN}✔ All Done!${COLOR_NONE}"
exit 0