-
Notifications
You must be signed in to change notification settings - Fork 11
/
install.sh
executable file
·163 lines (134 loc) · 4.34 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
#!/bin/sh
# This script installs these dotfiles.
set -e -u
printf '\e[1mInstalling dotfiles\e[0m\n'
case "$(uname)" in
'Linux')
if [ ! -x "$(command -v pacman)" ]; then
printf '\e[1mArch Linux is the only distro currently supported for automated setup\e[0m\n'
exit 1
fi
# Install Git if not installed
if [ ! -x "$(command -v git)" ]; then
printf '\e[1mInstalling Git\e[0m\n'
sudo pacman -S --noconfirm --needed git
fi
# git clone these dotfiles if not done yet
if [ ! -d ~/dotfiles ]; then
printf '\e[1mCloning dotfiles repo\e[0m\n'
git clone https://github.com/cloudlena/dotfiles.git ~/dotfiles
fi
# Install Stow if not installed
sudo pacman -S --noconfirm --needed stow
# Remove existing config files
if [ -f ~/.zshrc ]; then
rm ~/.zshrc
fi
if [ -f ~/.zshenv ]; then
rm ~/.zshenv
fi
# Stow subdirectories of dotfiles
printf '\e[1mLinking dotfiles to your home directory\e[0m\n'
for dir in ~/dotfiles/*/; do
stow --dir ~/dotfiles --target ~ "$(basename "${dir}")"
done
sudo pacman -Rns --noconfirm stow
# Install Paru if not installed
if [ ! -x "$(command -v paru)" ]; then
printf '\e[1mInstalling Paru\e[0m\n'
git clone https://aur.archlinux.org/paru-bin.git /tmp/paru
(cd /tmp/paru && makepkg -si)
fi
# Set colors for pacman
sudo sed -i 's/#Color/Color/' /etc/pacman.conf
# Install Pacmanfile if not installed
if [ ! -x "$(command -v pacmanfile)" ]; then
printf '\e[1mInstalling Pacmanfile\e[0m\n'
paru -S --noconfirm --needed pacmanfile
fi
# Install packages using Pacmanfile
printf '\e[1mInstalling desired packages using Pacmanfile\e[0m\n'
pacmanfile sync --noconfirm
# Change npm folder
if [ -x "$(command -v npm)" ]; then
npm set prefix="$HOME/.local"
fi
;;
'Darwin')
# Install Xcode Command Line Tools if not installed
if ! xcode-select -p >/dev/null; then
printf 'Xcode Command Line Tools not installed. You will have to run the script again after successfully installing them. Install now? (Y/n)'
read -r
echo
if ! "$REPLY" | grep -Eq '^[Nn]'; then
xcode-select --install
echo 'Please run the script again after the installation has finished'
else
echo 'Please install the Xcode Command Line Tools and run then script again.'
fi
exit
fi
# Install Homebrew if not installed
if [ ! -x "$(command -v brew)" ]; then
printf '\e[1mInstalling Homebrew\e[0m\n'
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Install git if not installed
if [ ! -x "$(command -v git)" ]; then
printf '\e[1mInstalling Git\e[0m\n'
brew install git
fi
# git clone these dotfiles if not done yet
if [ ! -d ~/dotfiles ]; then
printf '\e[1mCloning dotfiles repo\e[0m\n'
git clone https://github.com/cloudlena/dotfiles.git ~/dotfiles
fi
# Install Stow if not installed
if [ ! -x "$(command -v stow)" ]; then
brew install stow
fi
# Remove existing config files
if [ -f ~/.zshrc ]; then
rm ~/.zshrc
fi
# Stow subdirectories of dotfiles
printf '\e[1mLinking dotfiles to your home directory\e[0m\n'
for dir in ~/dotfiles/*/; do
stow --dir ~/dotfiles --target ~ "$(basename "${dir}")"
done
# Remove Stow
brew uninstall stow
# Install packages using Brewfile
printf '\e[1mInstalling desired packages using Pacmanfile\e[0m\n'
brew update
brew upgrade
cat ~/.config/homebrew/*Brewfile | brew bundle --file=-
# Install the Python Neovim package
pip3 install --upgrade --user pynvim
# Install additional Go tooling currently not available via Homebrew
go install golang.org/x/tools/cmd/goimports@latest
# Set dark mode
sudo defaults write /Library/Preferences/.GlobalPreferences AppleInterfaceTheme Dark
;;
# Default
*)
printf '\e[1mOS not supported for automated setup. Please install manually.\e[0m\n'
exit 1
;;
esac
# Install prezto
if [ ! -d ~/.zprezto ]; then
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
fi
# Use zsh
if [ -x "$(command -v zsh)" ] && [ "$SHELL" != "$(command -v zsh)" ]; then
printf '\e[1mChanging your shell to zsh\e[0m\n'
grep -q -F "$(command -v zsh)" /etc/shells || sudo sh -c 'echo "$(command -v zsh)" >> /etc/shells'
chsh -s "$(command -v zsh)"
fi
# Remove existing bash config files
rm -rf ~/.bash*
# Run full system upgrade
. ~/dotfiles/zsh/.zsh.d/functions.zsh
EDITOR=nvim pacu
printf '\e[1mDotfiles successfully installed. Please reboot to finalize.\e[0m\n'