ubuntu常用工具和python虚拟环境安装脚本

Make it easy to reuse. If it’s easy to reuse, people will. Create an environment that supports reuse.

经常装ubuntu的环境,每次都要重新把vim,tmux等工具安装上,最近整理了一下安装脚本。地址在这个https://github.com/PegasusWang/linux_config。包含了tmux,vim,docker,zsh等开发常用的工具,vim为python做了配置,包含了各种常用功能。

#!/usr/bin/env bash

#for zh-cn utf8 ubuntu14.04
sudo apt-get update
sudo apt-get install -y language-pack-zh-hant-base language-pack-zh-hans-base language-pack-zh
sudo locale-gen zh_CN.UTF-8
echo 'LC_ALL="zh_CN.UTF-8"' | sudo tee -a /etc/environment
sudo dpkg-reconfigure locales

#for ubuntu common tools
sudo apt-get install -y vim curl tmux build-essential zsh git wget ssh make
sudo apt-get install -y silversearcher-ag
sudo apt-get install -y gnome-tweak-tool
sudo apt-get install -y trash-cli

# open terminal in finder
sudo apt-get install -y nautilus-open-terminal
nautilus -q

# install zsh
wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
chsh -s /bin/zsh
cp ./ubuntu_zshrc ~/.zshrc


# for docker install ubuntu14.04
#sudo apt-get update
#sudo apt-get install -y apt-transport-https ca-certificates
#sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
#echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' | sudo tee /etc/apt/sources.list.d/docker.list
#sudo apt-get update
#sudo apt-get purge lxc-docker
#sudo apt-cache policy docker-engine
#sudo apt-get install -y docker-engine
#sudo service docker start
#sudo docker run hello-world

# https://get.daocloud.io
curl -sSL https://get.daocloud.io/docker | sh
curl -L https://get.daocloud.io/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

# for vim
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
cp ./ubuntu_vimrc ~/.vimrc
vim +PluginInstall +qall


# modify capslock to ctrl
# sudo vi /etc/default/keyboard
echo 'XKBOPTIONS="ctrl:nocaps"' | sudo tee -a /etc/default/keyboard
sudo dpkg-reconfigure keyboard-configuration


# restart
sudo reboot -h 0

# if you want to use terminal solarized color
# https://github.com/Anthony25/gnome-terminal-colors-solarized


# install nvm and nodejs
curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash
echo 'registry =https://registry.npm.taobao.org' > ~/.npmrc

还有一个python虚拟环境的安装,为了避免各种依赖问题,从docker hub的python镜像里边抠出来需要安装的各种依赖,基本上不会再碰到pip各种安装失败的问题。python虚拟环境使用pyenv。注意用source执行这个脚本。你可以按需修改,我在虚拟机测试成功,省了不少事情。

#!/usr/bin/env bash

# !!!note: use "source py_install.sh" instead of ./py_install.sh
# pyenv need
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
    libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev


sudo apt-get install -y build-essential libssl-dev libevent-dev libjpeg-dev libxml2-dev libxslt-dev build-dep libpq-dev
sudo apt-get install -y python-pip
sudo apt-get install -y python-distribute
sudo apt-get install -y python-dev
sudo apt-get install -y ipython
sudo apt-get install -y zlib1g-dev
sudo apt-get install -y libudev-dev
sudo apt-get install -y libffi-dev   # for brycpt

# https://github.com/docker-library/buildpack-deps/blob/e7534be05255522954f50542ebf9c5f06485838d/jessie/Dockerfile
sudo apt-get install -y --no-install-recommends \
        autoconf \
        automake \
        bzip2 \
        file \
        g++ \
        gcc \
        imagemagick \
        libbz2-dev \
        libc6-dev \
        libcurl4-openssl-dev \
        libdb-dev \
        libevent-dev \
        libffi-dev \
        libgeoip-dev \
        libglib2.0-dev \
        libjpeg-dev \
        liblzma-dev \
        libmagickcore-dev \
        libmagickwand-dev \
        libmysqlclient-dev \
        libncurses-dev \
        libpng-dev \
        libpq-dev \
        libreadline-dev \
        libsqlite3-dev \
        libssl-dev \
        libtool \
        libwebp-dev \
        libxml2-dev \
        libxslt-dev \
        libyaml-dev \
        make \
        patch \
        xz-utils \
        zlib1g-dev \



# https://github.com/yyuu/pyenv
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
cp ./ubuntu_zshenv ~/.zshenv
alias pyenv="~/.pyenv/bin/pyenv"
#exec "$SHELL"
pyenv install 2.7.11
pyenv install 3.5.0

# https://github.com/yyuu/pyenv-virtualenv
pyenv virtualenv 2.7.11 pyenv_2.7.11
pyenv virtualenv 3.5.0 pyenv_3.5.0

mkdir -p ~/project/pyenv_2.7.11
mkdir -p ~/project/pyenv_3.5.0

exit

嗯,具体的可以参考github目录,包括zshrc配置和vimrc的配置。主要是针对python开发环境,还有前端的coffee和js等。vim有一些很棒的插件可以在vimawesome这个网站找到,我把排名前几的都安装了,确实方便不少。