-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·243 lines (191 loc) · 5.42 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/env zsh
set -e
DOTFILES_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
INSTALL_DIR=$DOTFILES_DIRECTORY/install
CONFIG_FILE=$DOTFILES_DIRECTORY/config.sh
ALL_ENVIRONMENT_FILE=$DOTFILES_DIRECTORY/env_all.sh
GIT_CONFIG_CREDENTIALS_FILE=$DOTFILES_DIRECTORY/dots/.gitconfig.credentials
GIT_CONFIG_CRENDENTIAL_METHOD=osxkeychain
BASHRC=~/.zshrc
OHMYZSHDIRECTORY=$HOME/.oh-my-zsh
TITLE_MESSAGE="Escrichov Dotfiles"
COLOUR_STEP=green
COLOUR_TITLE=yellow
COLOUR_VARIABLE=yellow
function _term() {
echo-colour red "Installation script stopped"
exit 1
}
function print_title ()
{
echo-colour $COLOUR_TITLE "$TITLE_MESSAGE"
}
function print_variable ()
{
echo-colour $COLOUR_VARIABLE "$1: $2"
}
function print_step ()
{
echo-colour $COLOUR_STEP "* $1"
}
function print_error ()
{
echo-colour red "$1"
_term
}
# Source all environment
source $ALL_ENVIRONMENT_FILE
# Catch signals to exit correctly
trap _term SIGTERM
trap _term INT
# Print dotfiles title
print_title
# Ask for sudo only first
print_step "Ask for sudo password upfront"
sudo -v # ask for sudo upfront
# Create configuration file with Name, Email
if [ ! -f "$CONFIG_FILE" ]
then
print_step "Creating configuration file"
echo -n "Enter full name: "
read NAME
echo -n "Enter email: "
read EMAIL
cat <<EOT >> $CONFIG_FILE
#!/usr/bin/env bash
NAME="$NAME"
EMAIL="$EMAIL"
EOT
echo "Config file saved in $CONFIG_FILE"
else
source $CONFIG_FILE
fi
# Install or Update Brew
(
BREW_BIN=$BREW_PATH/bin/brew
if [ ! -f $BREW_BIN ]; then
print_step "Installing Brew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
print_step "Updating Brew"
brew update
brew upgrade
fi
# Disable analytics
brew analytics off
)
# Configure MacOS X Preferences that required sudo permissions
(
cd $INSTALL_DIR/macosx
print_step "Xcode command line developer tools"
./xcode.sh
print_step "Installing system Preferences"
sudo ./osx-system-defaults.sh
)
# Install Brew packages
(
cd $INSTALL_DIR/brew
print_step "Installing Brew packages and applications"
brew bundle
)
# Install dotfiles
(
print_step "Installing dotfiles"
stow --target=$HOME --dir=$DOTFILES_DIRECTORY dots
)
# NNN plugins
(
curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh
)
# Install npm packages
(
cd $INSTALL_DIR/node
print_step "Installing NPM Packages"
./npm.sh
)
# Install ruby packages
(
cd $INSTALL_DIR/ruby
print_step "Installing Ruby Gem Packages"
./gems.sh
)
# Install poetry with pipx
(
pipx install poetry
poetry config virtualenvs.in-project true
)
# Install NVM Directory
(
mkdir $HOME/.nvm
)
# Install Oh my ZSH
(
if [ ! -d "$OHMYZSHDIRECTORY" ]; then
print_step $COLOUR "Installing OH MY ZSH"
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
fi
)
# Install Powerline fonts
(
print_step "Installing Powerline Fonts"
git clone https://github.com/powerline/fonts.git --depth=1 /tmp/fonts
cd /tmp/fonts
./install.sh
/bin/rm -rf /tmp/fonts
)
# Customize Oh my ZSH
(
print_step "Customizing Oh my ZSH"
# Set templace robbyrussell by agnoster
sed -i '' 's/ZSH_THEME=.*/ZSH_THEME="agnoster"/' $BASHRC
# Add Default user to hid user@host line in prompt
grep -q -F "DEFAULT_USER=$(whoami)" $BASHRC || echo "DEFAULT_USER=$(whoami)" >> $BASHRC
# Installing Syntax Highlighting & Autosuggestions
ZSH_SYNTAX_HIGHLIGHTING_PATH=$BREW_PATH/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
grep -q -F "source $ZSH_SYNTAX_HIGHLIGHTING_PATH" $BASHRC || echo "source $ZSH_SYNTAX_HIGHLIGHTING_PATH" >> $BASHRC
ZSH_AUTOSUGGESTIONS_PATH=$BREW_PATH/share/zsh-autosuggestions/zsh-autosuggestions.zsh
grep -q -F "source $ZSH_AUTOSUGGESTIONS_PATH" $BASHRC || echo "source $ZSH_AUTOSUGGESTIONS_PATH" >> $BASHRC
)
# Install profile sources in ZSH
(
print_step "Installing source files to ZSH"
grep -q -F "source $DOTFILES_DIRECTORY/env_all.sh" $BASHRC || echo "source $DOTFILES_DIRECTORY/env_all.sh" >> $BASHRC
)
# Install fzf autocompletion
(
print_step "Installing fuzzy finder (fzf)"
$(brew --prefix)/opt/fzf/install --key-bindings --completion --no-update-rc
)
# Generate new id_rsa only if not exists
(
if [ ! -f ~/.ssh/id_ed25519 ]; then
print_step "Installing New Elliptic Curve ed25519 Private Key"
ssh-keygen -t ed25519 -C "$EMAIL"
fi
)
# Configure git name, email and credentials method
(
print_step "Configure git name and email"
touch $GIT_CONFIG_CREDENTIALS_FILE
git config --file $GIT_CONFIG_CREDENTIALS_FILE user.name "$NAME"
git config --file $GIT_CONFIG_CREDENTIALS_FILE user.email $EMAIL
git config --file $GIT_CONFIG_CREDENTIALS_FILE credential.helper $GIT_CONFIG_CRENDENTIAL_METHOD
)
# Configure MacOS X Preferences
(
cd $INSTALL_DIR/macosx
print_step "Setup DNS servers"
./dns.sh
print_step "Installing user preferences"
./osx-user-defaults.sh
print_step "Installing dock preferences"
/usr/bin/python setup-dock.py
print_step "Default login items"
/usr/bin/python setup-login-items.py
print_step "Bind file extensions to apps"
/usr/bin/python file-extensions.py
)
# Restore configuration of apps
print_step "Restore apps configuration and preferences"
mackup restore -f
exit 0