-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·161 lines (131 loc) · 3.29 KB
/
install
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env bash
set -euo pipefail
root="${HOME}"/.dotfiles
packages=("tmux" "git" "zsh")
# add zsh as a login shell
# command -v zsh | sudo tee -a /etc/shells
check() {
if ! command -v git >/dev/null; then
echo Install git first
return 1
fi
if ! command -v curl >/dev/null; then
echo Install cURL first
return 1
fi
return 0
}
check-mac() {
if [[ ! "$(uname)" =~ Darwin ]]; then
return 0;
else
return 1;
fi
}
backup() {
target=$1
if [ -e "$target" ]; then
if [ ! -L "$target" ]; then
mv "$target" "$target.backup"
echo "-----> Moved your old $target config file to $target.backup"
fi
fi
}
symlink() {
file=$1
link=$2
if [ ! -e "$link" ]; then
echo "-----> Symlinking your new $link"
ln -s $file $link
fi
}
install-code() {
CODE_PATH=~/Library/Application\ Support/Code/User
for name in settings.json keybindings.json; do
target="$CODE_PATH/$name"
backup $target
symlink $PWD/$name $target
done
}
# install-apps() {
# return 0
# # if [[ ! "$(uname)" =~ Darwin ]]; then return 0; fi
# # pushd "${root}" || return 1
# # echo Installing apps...
# # toolset/Apps install
# # popd
# # return $?
# }
install-clt() {
if check-mac; then return 0; fi
if command -v xcode-select >/dev/null; then return 0; fi
echo Installing Command Line Tools for Xcode...
xcode-select --install
return $?
}
install-dotfiles() {
if [ -d "${root}" ]; then return 0; fi
echo Installing dotfiles...
mkdir -p "${root}"
git clone [email protected]:fc-arny/.dotfiles.git "${root}"
return $?
}
install-homebrew() {
if check-mac; then return 0; fi
if command -v brew >/dev/null; then return 0; fi
echo Installing Homebrew... # https://docs.brew.sh/Installation
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
local bin
if [ -x '/usr/local/bin/brew' ]; then bin='/usr/local/bin/brew'; fi
if [ -x '/opt/homebrew/bin/brew' ]; then bin='/opt/homebrew/bin/brew'; fi
if [ -x '/home/linuxbrew/.linuxbrew/bin/brew' ]; then bin='/home/linuxbrew/.linuxbrew/bin/brew'; fi
if [ -z "${bin}" ]; then
echo Homebrew not found after installation
return 1
fi
eval "$(${bin} shellenv)"
chmod -R go-w "$(brew --prefix)/share/zsh"
return $?
}
install-bundle() {
if check-mac; then return 0; fi
echo Installing Homebrew bundle...
brew tap --repair
brew update --force --quiet
brew bundle --file="${root}"/toolset/Brewfile --no-upgrade -v
brew bundle --file="${root}"/toolset/Brewfile cleanup -v
return $?
}
# install-tools() {
# pushd "${root}" || return 1
# echo Installing tools...
# make install
# popd
# return $?
# }
integrate-cli() {
for package in "${packages[@]}"; do
stow -t "$HOME" "$package"
if [ $? -eq 0 ]; then
echo "Package $package successfully installed"
else
echo "Error while installing package $package."
fi
done
if command -v zsh >/dev/null; then
if [ ! -d "${HOME}/.oh-my-zsh" ]; then
echo Installing Oh My Zsh...
bash -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
fi
return 0
}
if ! check; then return 0; fi
# install-clt
# install-dotfiles
# install-homebrew
# install-bundle
# # install-tools
# # install-apps
# integrate-cli
install-code