Last active
August 16, 2024 10:39
-
-
Save murphypei/06f8ca1c28a96644ed8c5a50e763597c to your computer and use it in GitHub Desktop.
ubuntu dev env setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -x | |
function install_zsh() { | |
sudo apt update | |
sudo apt install -y zsh curl | |
sudo usermod -s /bin/zsh $(whoami) | |
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
} | |
function setup_zsh() { | |
# install_zsh | |
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting | |
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions | |
git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions | |
git clone https://github.com/paulirish/git-open.git ~/.oh-my-zsh/custom/plugins/git-open | |
sudo apt install -y autojump | |
# set oh-my-zsh | |
sed -i "s/robbyrussell/steeef/g" ~/.zshrc | |
sed -i "3iexport TERM=xterm-256color" ~/.zshrc | |
sed -i "s/#\ DISABLE_AUTO_UPDATE/DISABLE_AUTO_UPDATE/g" ~/.zshrc | |
sed -i "s/#\ COMPLETION_WAITING_DOTS/COMPLETION_WAITING_DOTS/g" ~/.zshrc | |
sed -i "s/plugins=(git)/plugins=(git\ autojump\ zsh-autosuggestions\ zsh-syntax-highlighting\ git-open)/g" ~/.zshrc | |
echo "alias rsynca=\"rsync -avzP\"" >>~/.zshrc | |
echo "alias py_http=\"python -m SimpleHTTPServer 8001\"" >>~/.zshrc | |
echo "alias valgrinda=\"valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all\"" >>~/.zshrc | |
source ~/.zshrc | |
} | |
function setup_vim() { | |
sudo apt update | |
sudo apt install -y vim | |
git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime | |
sh ~/.vim_runtime/install_awesome_vimrc.sh | |
echo "set number" >>~/.vimrc | |
echo "set cursorcolumn" >>~/.vimrc | |
echo "set cursorline" >>~/.vimrc | |
} | |
function set_git() { | |
# install git | |
sudo add-apt-repository ppa:git-core/ppa | |
sudo apt update | |
sudo apt install -y git | |
wget https://gist.githubusercontent.com/murphypei/c783c78282d8caae5b4d7b5c8870fc52/raw/8c68a27e5197c80adfe5fbd3983682b9fba821f5/.gitconfig | |
# install git-lfs | |
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash | |
sudo apt install -y git-lfs | |
} | |
function setup_python() { | |
PYTHON_VERSION=3.9.9 | |
VIRTUAL_ENV=env399 | |
SHRC=bashrc | |
# SHRC=zshrc | |
git clone https://github.com/yyuu/pyenv.git ~/.pyenv | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >>~/.$SHRC | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >>~/.$SHRC | |
echo 'eval "$(pyenv init -)"' >>~/.$SHRC | |
exec $SHELL | |
source ~/.$SHRC | |
pyenv install -v $PYTHON_VERSION | |
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv | |
echo 'eval "$(pyenv virtualenv-init -)"' >>~/.$SHRC | |
source ~/.$SHRC | |
pyenv virtualenv $PYTHON_VERSION $VIRTUAL_ENV | |
pyenv activate $VIRTUAL_ENV | |
source ~/.pyenv/version/$VIRTUAL_ENV/bin/activate | |
} | |
function install_code() { | |
# vscode | |
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" | |
sudo apt update && sudo apt install code | |
# install build tools | |
sudo apt update | |
sudo apt install -y tmux build-essential curl make | |
# install clang clang format | |
# sudo apt update | |
# sudo apt install -y clang clang-format | |
# install latest cmake | |
sudo apt-get install apt-transport-https ca-certificates gnupg software-properties-common wget | |
wget -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo apt-key add - | |
sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | |
sudo apt update | |
sudo apt install -y cmake | |
} | |
function setup_docker() { | |
sudo apt update | |
sudo apt install apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt update | |
apt-cache policy docker-ce | |
sudo apt install -y docker-ce | |
# check docker status | |
sudo systemctl status docker | |
# run docker command without sudo | |
sudo usermod -aG docker ${USER} | |
su - ${USER} # 可能不生效,需要重启 | |
# confirm docker group | |
id -nG | |
} | |
setup_zsh | |
setup_git | |
setup_vim | |
setup_python |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment