LoginSignup
5
14

More than 5 years have passed since last update.

msys2 + MinGW64 でWindows10にターミナル環境構築

Last updated at Posted at 2017-10-08

やりたかったこと

  • windows10でもzsh+tmux+powerlineの環境が欲しかった(結局vim-airlineを使ってる)。
  • ファイルをvimで快適に編集したかった。
  • $ vagrant ssh のコマンドでvagrant + virtual boxの仮想環境に接続したかった。

(参照: [仮想環境]コピペでOK!Vagrant + VM VirtualBox で Rails開発環境[windows10])

特に最後の問題がなかなか突破できずに、今回の方法に至りました。

ダウンロード

https://msys2.github.io/
から MSYS2 のインストーラを取得して実行。

アップデート・mingw他のインストール

$ pacman -Syuu
$ pacman -S base-devel
$ pacman -S mingw-w64-x86_64-toolchain
$ pacman -S openssh vim zsh tmux git

環境変数 PATH の設定(windows10の場合)

デフォルトでは、Windows の環境変数 PATH の設定を 引き継がない。
コントロールパネル → システムとセキュリティ → システム → システムの詳細設定 →詳細設定 → 環境変数 から
Windows の環境変数に MSYS2_PATH_TYPE を追加し、値を inherit に設定する。

デフォルトのシェルをzshに変更 (C:\msys64\msys2_shell.cmd を編集 )

\msys64\msys2_shell.cmd
#79行目付近
# start "%CONTITLE%" "%WD%mintty" -i /msys2.ico /usr/bin/bash --login %1 %2 %3 %4 %5 %6 %7 %8 %9
start "%CONTITLE%" "%WD%mintty" -i /msys2.ico /usr/bin/zsh --login %1 %2 %3 %4 %5 %6 %7 %8 %9

ホームディレクトリを任意の場所に変更 (‪C:\msys64\etc\fstab を編集 )

\msys64\etc\fstab
# For a description of the file format, see the Users Guide
# http://cygwin.com/cygwin-ug-net/using.html#mount-table

# DO NOT REMOVE NEXT LINE. It remove cygdrive prefix from path
none / cygdrive binary,posix=0,noacl,user 0 0
C:/Users/◯◯ /home/◯◯ #追記

powerline

(pythonが動作しているか確認)

$ python
Python 2.7.9 (default, Mar 1 2015, 12:57:24)                                                      
[GCC 4.9.2] on linux2 
Type "help", "copyright", "credits" or "license" for more information.
>>>exit()
(などと表示されればOK)

$ curl -O https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
$ pip install --user git+git://github.com/powerline/powerline
$ pacman -S socat
$ pip install psutil
$ pip install pyuv

vimのプラグイン管理(neobundle)・colorscheme

配置先のディレクトリを作成

$ mkdir -p ~/.vim/bundle

NeoBundleをリポジトリから取得

$ git clone git://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim

colorscheme(molokai)

$ mkdir ~/.vim
$ cd ~/.vim
$ mkdir colors
$ git clone https://github.com/tomasr/molokai
$ mv molokai/colors/molokai.vim ~/.vim/colors/

※tmuxを起動すると[exited]と表示されて強制終了する場合

  • .tmux.conf で default-shell(command) の path を確認
  • perl -pi -e 's/\r$//' ~/.tmux.conf を実行

※tmuxを起動すると勝手にbashが起動する場合 (~/.tmux.confを編集)

~/.tmux.conf
set -g default-shell /bin/zsh
5
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
14