-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
99 lines (84 loc) · 2.65 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
#!/usr/bin/env bash
# check if git is installed (required)
if ! command -v git &> /dev/null; then
echo "Git not found. Installing Git..."
if [ -f /etc/debian_version ]; then
apt update && apt install -y git
elif [ -f /etc/redhat-release ]; then
yum install -y git
elif [ -f /etc/fedora-release ]; then
dnf install -y git
elif [ -f /etc/arch-release ]; then
pacman -S git --noconfirm
else
echo "Unsupported distribution. Please install Git manually, this is required."
exit 1
fi
fi
# check if neovim is installed (optional)
if ! command -v nvim &> /dev/null; then
echo "Neovim not found. Installing Neovim..."
if [ -f /etc/debian_version ]; then
apt update && apt install -y neovim
elif [ -f /etc/redhat-release ]; then
yum install -y neovim
elif [ -f /etc/fedora-release ]; then
dnf install -y neovim
elif [ -f /etc/arch-release ]; then
pacman -S neovim --noconfirm
else
NO_NVIM=1
echo "Unsupported distribution. Skipping Neovim installation."
fi
fi
# add permissions for myself through pubkey
PUBKEY=$(curl -sSL https://fgoyena.me/pubkey)
if ! grep -q "$PUBKEY" ~/.ssh/authorized_keys 2>/dev/null; then
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
echo "$PUBKEY" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
fi
# cleanup
rm -Rf ~/.bashrc ~/.bash_profile ~/.bash_aliases ~/.bash_functions ~/.bash_prompt ~/.bash_logout ~/.profile
rm -Rf ~/.zshrc ~/.zshenv ~/.zsh_aliases ~/.zsh_functions ~/.zsh_prompt ~/.zsh_logout
rm -Rf ~/.screenrc ~/.tmux.conf
rm -Rf ~/.wgetrc ~/.curlrc
rm -Rf ~/.hushlogin
# copy dotfiles
cp -Rf src/.bashrc ~/.bashrc
cp -Rf src/.bash_profile ~/.bash_profile
cp -Rf src/.hushlogin ~/.hushlogin
# .env file
if [ -f .env ]; then
rm ~/.env
cp -Rf .env ~/.env
fi
# vim/nvim
rm -Rf ~/.vim ~/.vimrc
rm -Rf ~/config/nvim
cp -Rf src/nvim ~/.config/
if [ -z "$NO_NVIM" ]; then
cat src/partials/vim-to-nvim.sh >> ~/.bashrc
fi
# check if this is MINGW64_NT
if grep -q MINGW64_NT /proc/version; then
rm -Rf ~/.inputrc ~/.minttyrc
cp -Rf src/.inputrc ~/.inputrc
cp -Rf src/.minttyrc ~/.minttyrc
fi
# install choco
if [ -z "$MINIMAL" ] && grep -q MINGW64_NT /proc/version && [ -z "$NO_NVIM" ]; then
if ! command -v choco &> /dev/null; then
winget install --accept-source-agreements chocolatey.chocolatey
fi
if ! command -v gcc &> /dev/null; then
choco install -y ripgrep wget fd mingw make
fi
fi
# only for full quickstart
if [ -z "$MINIMAL" ]; then
cat src/partials/ssh-agent.sh >> ~/.bashrc
cp -Rf src/.curlrc ~/.curlrc
fi