Skip to content

Instantly share code, notes, and snippets.

@kingsamchen
Last active May 20, 2022 14:55
Show Gist options
  • Save kingsamchen/3a9402efadd1bf9cadc8a16cbd16c687 to your computer and use it in GitHub Desktop.
Save kingsamchen/3a9402efadd1bf9cadc8a16cbd16c687 to your computer and use it in GitHub Desktop.
#!/bin/env bash
# Target to ubuntu-20.04 TLS
sudo apt-get install \
byobu build-essential \
git \
htop \
ncdu \
vim \
openssh-server \
python3-pip \
socat \
zsh \
-y
sudo cat <<EOT > /lib/systemd/system/proxy-agent.service
[Unit]
Description=Porxy agent
[Service]
ExecStart=socat tcp-l:10080,fork,reuseaddr tcp:192.168.50.201:10080
Type=simple
[Install]
WantedBy=multi-user.target
Restart=on-failure
EOT
sudo systemctl daemon-reload
sudo systemctl enable proxy-agent
sudo systemctl start proxy-agent
# os
sudo -- sh -c 'echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf' && sudo sysctl -p
mkdir ~/programs
# git
cat <<EOT > ~/.gitconfig
[user]
name = Kingsley Chen
email = kingsamchen@gmail.com
[core]
autocrlf = input
editor = vim
[i18n]
filesEncoding = utf-8
[http]
proxy = http://127.0.0.1:10080
[https]
proxy = http://127.0.0.1:10080
sslverify=false
[alias]
lg = log --graph --pretty=format:'%C(yellow)%d%Creset %C(cyan)%h%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=short --all
del-remote = push origin --delete
[credential]
helper = store
[merge]
conflictstyle = diff3
EOT
# oh-my-zsh
sh -c "$(curl --proxy http://127.0.0.1:10080 -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="ys"/g' ~/.zshrc
sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions z)/g' ~/.zshrc
echo "setopt +o nomatch" >> ~/.zshrc
# Install clang-13 and related tools
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
llvm_version=13
repo_name="deb [arch=amd64] http://mirrors.tuna.tsinghua.edu.cn/llvm-apt/focal/ llvm-toolchain-focal-${llvm_version} main"
sudo add-apt-repository "${repo_name}"
sudo apt-get update
PKG="clang-$llvm_version lldb-$llvm_version lld-$llvm_version clangd-$llvm_version clang-tidy-$llvm_version clang-format-$llvm_version"
sudo apt-get install -y $PKG
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-13 130 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-13
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 40
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 40
sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-13 130
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-13 130
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 130
cat <<EOT > ~/.vscode-server/data/Machine/settings.json
{
"cmake.buildDirectory": "${workspaceFolder}/out/build/vscode",
"clangd.arguments": [
"--background-index",
"--compile-commands-dir=out/build/vscode",
"-j=8",
"--clang-tidy",
"--all-scopes-completion",
"--completion-style=detailed",
"--header-insertion=iwyu",
"--pch-storage=disk"
]
}
EOT
# wget with proxy
cat <<EOT > ~/.wgetrc
use_proxy=off
http_proxy=http://127.0.0.1:10080
https_proxy=http://127.0.0.1:10080
EOT
# byobu
mkdir -p ~/.byobu
echo "set-option -g mouse on" > ~/.byobu/.tmux.conf
# mcfly
cd ~/programs
MCFLY_URL="https://github.com/cantino/mcfly/releases/download/v0.6.0/mcfly-v0.6.0-x86_64-unknown-linux-musl.tar.gz"
MCFLY_OUT_NAME="mcfly-linux-musl.tar.gz"
wget --proxy $MCFLY_URL --output-document $MCFLY_OUT_NAME && tar -xzf $MCFLY_OUT_NAME
sudo ln -sf `realpath mcfly` /usr/local/bin/mcfly
echo 'eval "$(mcfly init zsh)"' >> ~/.zshrc
rm $MCFLY_OUT_NAME
# gitui
cd ~/programs
gitui_url="https://github.com/extrawurst/gitui/releases/download/v0.20.1/gitui-linux-musl.tar.gz"
gitui_out_name="gitui-linux-musl.tar.gz"
wget --proxy $gitui_url --output-document ${gitui_out_name} && tar xzf ${gitui_out_name}
sudo ln -sf `realpath gitui` /usr/local/bin/gitui
rm ${gitui_out_name}
# ninja-build
cd ~/programs
ninja_build_url="https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip"
ninja_build_out_name="ninja-build.zip"
wget --proxy ${ninja_build_url} -O ${ninja_build_out_name} && unzip ${ninja_build_out_name}
sudo ln -sf `realpath ninja` /usr/local/bin/ninja
rm ${ninja_build_out_name}
# cmake
cd ~/programs
cmake_url="https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-linux-x86_64.tar.gz"
wget --proxy ${cmake_url} && tar xzf cmake*.tar.gz
pushd cmake*/bin
sudo ln -sf `realpath cmake` /usr/local/bin/cmake
sudo ln -sf `realpath ctest` /usr/local/bin/ctest
popd
rm cmake*.tar.gz
# cpm.cmake cache
mkdir ~/.cache/cpp-cpm
echo 'export CPM_SOURCE_CACHE="$HOME/.cache/cpp-cpm"' >> ~/.zshrc
# change shell
chsh -s $(which zsh)
# No x-server by default
# sudo systemctl set-default multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment