Computer Science
Algorithm
Data Processing
Digital Life
Distributed System
Distributed System Infrastructure
Machine Learning
Operating System
Android
Linux
MacOS
Tizen
Windows
Build a Unix Like Environment on Windows (2016)
iOS
Programming Language
C++
Erlang
Go
Scala
Scheme
Type System
Software Engineering
Storage
UI
Flutter
Javascript
Virtualization
Life
Life in Guangzhou (2013)
Recent Works (2013)
东京之旅 (2014)
My 2017 Year in Review (2018)
My 2020 in Review (2021)
十三年前被隔离的经历 (2022)
A Travel to Montreal (2022)
My 2022 in Review (2023)
Travel Back to China (2024)
Projects
Bard
Blog
RSS Brain
Scala2grpc
Comment Everywhere (2013)
Fetch Popular Erlang Modules by Coffee Script (2013)
Psychology
耶鲁大学心理学导论 (2012)
Thoughts
Chinese
English

Build a Unix Like Environment on Windows

Posted on 28 Nov 2016, tagged WindowsPythonbash

I’ve bought a Surface Pro 4 some days ago. It is very amazing and I’d like to use it as my backup development laptop. My daily development is under Linux and Mac OS X. I use terminal and lots of bash scripts everyday. So I need a Unix-like environment on Windows. This article will introduce how to do that.

Terminal and Unix Tools

There is a famous software called Cygwin which provides many unix tools along with a terminal. You can download it from its homepage and install it with GUI.

While installing it, it will ask you which tools you’d like to install. Just install the default ones and Lynx is enough, since we will install a package manager and it will be easier to install other tools then.

You can use Xterm with Cygwin terminal, so you can config it as you are in Linux.

Package Manager

The most missed thing while I’m using Windows is Linux’s package manager. You can search, install, update and manage software very easily with it. There is also HomeBrew under Mac OS X so I’d like something like that under Windows. I searched on Google and found apt-cyg which can manage packages in Cygwin. You can follow the steps on its homepage to install it. After install it, you can install wget with it so that it will stop print warning messages.

I’ve installed tmux, zsh, Git and vim with it. And config them with my config files. I only need to change the tmux start up config:

- set -g default-command "reattach-to-user-namespace -l /bin/zsh"
+ set -g default-command "/usr/bin/zsh"

Except this, everything else works very well without any problem.

Python

There are many tools are written in Python. And my work also uses Python a lot. You can install Python with apt-cyg. But there will be some tricky things if you need to install some Python packages with pip.

First we will install pip:

apt-cyg install python python-devel
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
easy_install pip

Then we need to install gcc in order to compile some python packages:

apt-cyg install colorgcc gcc-core gcc-g++ libgcc1

Then we need to change a python header file: /usr/include/python2.7/pyconfig.h:

- #define __BSD_VISIBLE 1
+ #define __BSD_VISIBLE 0