Workspace Setup

Steps to set up my personal workspace.

apt

Project link: https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/

1
2
sudo sed -i "s@http://.*archive.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
sudo sed -i "s@http://.*security.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list

brew

1
2
3
4
5
6
7
8
9
# 查看 brew.git 当前源
$ cd "$(brew --repo)" && git remote -v
origin https://github.com/Homebrew/brew.git (fetch)
origin https://github.com/Homebrew/brew.git (push)

# 查看 homebrew-core.git 当前源
$ cd "$(brew --repo homebrew/core)" && git remote -v
origin https://github.com/Homebrew/homebrew-core.git (fetch)
origin https://github.com/Homebrew/homebrew-core.git (push)
1
2
3
4
5
6
7
8
9
10
11
# 替换各个源
$ git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc

# 刷新源
$ brew update
1
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api" #brew.idayer.com' >> ~/.zshrc

wget

1
vi ~/.wgetrc
1
2
http_proxy=http://localhost:10809
https_proxy=http://localhost:10809

git

editor

1
git config --global core.editor "vim"

user

1
2
git config --global user.email "songzy_thu@163.com"
git config --global user.name "Zhengyang Song"

ssh https

https://stackoverflow.com/questions/15589682/how-to-fix-ssh-connect-to-host-github-com-port-22-connection-timed-out-for-g

1
vi ~/.ssh/config
1
2
3
Host github.com
Hostname ssh.github.com
Port 443

zsh

1
sudo apt install zsh

https://github.com/ohmyzsh/ohmyzsh

1
2
3
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh

sh install.sh

p10k

https://github.com/romkatv/powerlevel10k

1
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Then in ~/.zshrc:

1
ZSH_THEME="powerlevel10k/powerlevel10k"

tmux

1
vi ~/.tmux.conf
1
2
set -g default-shell /usr/bin/zsh
set -g default-terminal "xterm-256color"

python

pip source

1
sudo apt install python3-pip

https://pip.pypa.io/en/stable/user_guide/#config-file
https://gist.github.com/MaHu6/228fe96b2b81c677ae5c950a6b8d55c4

1
2
3
4
5
6
7
mkdir ~/.pip

echo "[global]" > ~/.pip/pip.conf
echo " index-url = https://mirrors.aliyun.com/pypi/simple/" >> ~/.pip/pip.conf
echo "[install]" >> ~/.pip/pip.conf
echo " trusted-host=mirrors.aliyun.com" >> ~/.pip/pip.conf
echo "" >> ~/.pip/pip.conf

jupyter notebook

1
2
jupyter notebook --generate-config
vi ~/.jupyter/jupyter_notebook_config.py
1
c.NotebookApp.use_redirect_file = False
1
2
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user

virtualenvwrapper

1
sudo apt install virtualenv

https://virtualenvwrapper.readthedocs.io/en/latest/install.html

1
pip install virtualenvwrapper
1
2
# vi ~/.bashrc
vi ~/.zshrc
1
2
3
4
5
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
# source /usr/local/bin/virtualenvwrapper.sh
# source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
source ~/.local/bin/virtualenvwrapper.sh

nodejs

nvm

https://github.com/nvm-sh/nvm

1
2
wget -qO- 
https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
1
2
nvm ls
nvm ls-remote
1
nvm install 

npm registry

https://developer.aliyun.com/mirror/NPM

1
2
npm config get registry
npm config set registry http://registry.npmmirror.com

yarn registry

1
2
yarn config get registry
yarn config set registry http://registry.npmmirror.com

ruby

1
2
3
4
5
# 添加镜像源并移除默认源
gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
# 列出已有源
gem sources -l
# 应该只有镜像源一个

bundler

1
bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems

docker

1
2
3
4
5
6
mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
1
sudo service docker restart
1
docker info