-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·164 lines (138 loc) · 4.35 KB
/
install.sh
File metadata and controls
executable file
·164 lines (138 loc) · 4.35 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
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
#!/usr/bin/env bash
# Get timestamp
now=$(date +%s)
# GLOBAL PARAMETERS
FONTS="hack mononoki go-mono jetbrains-mono"
ASTRONVIM_REPO=https://github.com/AstroNvim/AstroNvim
MY_REPO=https://github.com/josephbharrison/nvim
# install base configuration only
[[ $1 == "base" ]] && echo "Installing base astronvim only" && BASE_ONLY=true
# Verify homebrew install
function check_prereqs(){
echo -en "Checking prereqs: "
res=$(brew list)
if [[ $? -ne 0 ]]; then
echo "MISSING"
echo "Installing homebrew: "
/bin/bash -c "NONINTERACTIVE=1 $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
}
function fail(){
echo "FAIL"
exit 1
}
function ok(){
echo "OK"
}
function install_fonts(){
# Install fonts
echo -en "Installing fonts: "
for font in $FONTS
do
res=$(brew list --cask font-${font}-nerd-font &> /dev/null)
if [[ $? -ne 0 ]]; then
sudo rm -f $HOME/Library/Fonts/${font}* &> /dev/null
brew tap homebrew/cask-fonts &> /dev/null &&
brew install --cask font-${font}-nerd-font &> /dev/null || return 1
fi
done
return 0
}
function install_tmux(){
# Install tmux
res=$(brew list tmux)
if [[ $? -ne 0 ]]; then
echo -en "Installing tmux: "
brew update &> /dev/null && brew install tmux &> /dev/null || return 1
else
echo -en "Updating tmux: "
brew upgrade tmux &> /dev/null || return 1
fi
return 0
}
function install_wezterm(){
# Install wezterm
res=$(brew list wezterm-nightly)
if [[ $? -ne 0 ]]; then
echo -en "Installing wezterm: "
brew tap wez/wezterm &> /dev/null
brew update &> /dev/null && brew install --cask wez/wezterm/wezterm-nightly &> /dev/null || return 1
else
echo -en "Updating wezterm: "
brew upgrade --cask wezterm-nightly --no-quarantine --greedy-latest &> /dev/null | return 1
fi
return 0
}
function install_neovim(){
# Install dependencies
res=$(brew list nvim)
if [[ $? -ne 0 ]]; then
echo -en "Installing neovim: "
brew update &> /dev/null && brew install nvim &> /dev/null || return 1
else
echo -en "Updating neovim: "
brew upgrade nvim &> /dev/null || return 1
fi
return 0
}
# Configure NeoVim
function configure_environment(){
echo -en "Configuring environment: "
config_dir=${HOME}/.config
extras_dir=${config_dir}/nvim/extras
# Backup configuration
[[ -d $config_dir ]] && mv -f $config_dir ${config_dir}.${now}.bak
mv -f ~/.bash_profile ~/.bash_profile.${now}.bak
# Create config directory
mkdir -p $config_dir
# Backup nvim packages
nvim_local_dir=${HOME}/.local/share/nvim
nvim_site_dir=${nvim_local_dir}/site
[[ -d $nvim_site_dir ]] && mv -f $nvim_site_dir ${nvim_site_dir}.${now}.bak
# Install nvim configuration
nvim_config_dir=${config_dir}/nvim
if [[ $BASE_ONLY != true ]];then
git clone $MY_REPO $nvim_config_dir &> /dev/null || return 1
else
git clone $ASTRONVIM_REPO $nvim_config_dir &> /dev/null || return 1
fi
# Configure tmux
mkdir -p $config_dir/tmux
cp $extras_dir/tmux/tmux.conf $config_dir/tmux/tmux.conf
git clone https://github.com/tmux-plugins/tpm ~/.config/tmux/plugins/tpm &> /dev/null || return 1
# Configure wezterm
mkdir -p $config_dir/wezterm
cp $extras_dir/wezterm/wezterm.lua $config_dir/wezterm/wezterm.lua
# Configure starship
mkdir -p $config_dir/starship
cp $extras_dir/starship/* $config_dir/starship/
cp $extras_dir/starship/default.toml $config_dir/starship.toml
# Configure bash
cp $extras_dir/bash/.bash_profile ${HOME}/.bash_profile
return 0
}
function packer_count(){
echo $(ps -ef | grep -c "/[p]acker/")
}
function packer_sync(){
# HEADLESS INSTALL
echo -en "Updating packages: "
nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync' &> /dev/null &
while [[ $(packer_count) -gt 0 ]]
do
sleep 1
done
}
function install(){
installers="check_prereqs install_fonts install_tmux install_wezterm install_neovim configure_environment packer_sync"
for installer in $installers
do
$installer && ok || fail
done
}
install
echo
echo "Installation complete, run:"
echo
echo " wezterm start nvim +PackerSync"
echo