-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·159 lines (132 loc) · 4.2 KB
/
setup.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
#!/usr/bin/env bash
set -e
#
# For Mac and Linux
#
repoRoot=$(realpath "$(dirname "$0")")
source "${repoRoot}/lib/libxnix.sh"
packagesCommon=(
# essentials
zsh tmux neovim
htop glances ripgrep
curl wget file unzip gpg jq
# VCS
git git-lfs tig subversion
# For asdf (Build tools)
coreutils automake autoconf openssl libtool unixodbc bison gettext openssl pkg-config re2c
)
packagesMac=(
fd eza
coreutils libyaml readline libxslt libtool unixodbc gd
libjpeg mysql-connector-c oniguruma
)
# ubuntu
packagesLinux=(
fd-find apt-transport-https software-properties-common
build-essential libyaml-dev libxslt-dev libgd-dev libcurl4-openssl-dev libedit-dev libicu-dev
libjpeg-dev libmysqlclient-dev libonig-dev libpng-dev libpq-dev libsqlite3-dev libssl-dev libxml2-dev libzip-dev zlib1g-dev
)
packagesLinuxCargo=(
eza git-delta
)
# ----------------------------------
# Check Environment ($machine)
# ----------------------------------
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
# ----------------------------------
# Mac
# ----------------------------------
if [[ $machine = Mac ]] ; then
# Homebrew
if ! cex brew ; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
# Homebrew Packages
brew install "${packagesCommon[@]}" "${packagesMac[@]}"
# anyenv
if ! cex anyenv ; then
brew install anyenv
anyenv init
eval "$(anyenv init -)"
anyenv install --init
fi
# powerline
pip3 install --user powerline-status
# Screenshot behaviour
defaults write com.apple.screencapture type jpg
defaults write com.apple.screencapture disable-shadow -bool true
killall SystemUIServer
fi
# ----------------------------------
# Linux
# ----------------------------------
if [[ $machine = 'Linux' ]] ; then
read -p "Are you sure you want to install System Packages? Please input N to skip if you are on SHARED SERVER. (y/N): " -n 1 -r inst
echo
if [[ $inst =~ ^[Yy]$ ]] ; then
source /etc/os-release
sudo apt-get update
sudo apt-get install -y "${packagesCommon[@]}" "${packagesLinux[@]}"
if ! dpkg -s packages-microsoft-prod &>/dev/null ; then
wget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y powershell
rm packages-microsoft-prod.deb
fi
fi
if ! cex cargo ; then
if [[ -e $HOME/.cargo/env ]] ; then
source "$HOME/.cargo/env"
else
curl https://sh.rustup.rs -sSf | sh -s -- -y
fi
fi
~/.cargo/bin/rustup update
~/.cargo/bin/cargo install "${packagesLinuxCargo[@]}"
fi
# ----------------------------------
# ZSH
# ----------------------------------
[ -e ~/.zshrc ] || ln -s "$repoRoot/.zshrc" ~/.zshrc
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
if [[ ! -e $ZINIT_HOME ]] ; then
mkdir -p "$(dirname "$ZINIT_HOME")"
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi
sudo chsh "$USER" -s "$(which zsh)"
# ----------------------------------
# Common and PowerShell
# ----------------------------------
cex pwsh && pwsh -NoProfile "$repoRoot/setup.core.ps1"
# ----------------------------------
# Common over *NIX Platforms
# ----------------------------------
if [ ! -e ~/.fzf ] ; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
fi
if ! command -v asdf > /dev/null 2>&1 ; then
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
cd ~/.asdf
git checkout "$(git describe --abbrev=0 --tags)"
fi
if [ ! -d ~/.tmux/plugins/tpm ] ; then
mkdir -p ~/.tmux/plugins
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
else
pushd ~/.tmux/plugins/tpm/
git fetch --all --prune
git reset --hard origin/HEAD
popd
fi
"$repoRoot/git.sh"
zsh
# vim: et:ts=4:sw=4:ft=bash