LoginSignup
15
13

More than 5 years have passed since last update.

windows10でVirtualBoxを使ったターミナル環境を整える

Last updated at Posted at 2015-11-23

さいつよのターミナル環境を構築しようのひとがうらやましすぎたのだが手元にあるのは型落ちのwindowsのみでLinuxダブルブートは面倒くさいし毎日残業で再起動の時間ももったいないあなたにVirtualBoxはどうじゃろう。

2015-11-28.png
(2015/11/28 画面イメージ差し替え)

virtualbox に debian jessie インストール

debian なのは慣れてるからであって好きなディストリビューションを使えばよいと思う。X を入れなければ起動速度は boot2docker とタメ張る程度には早い(Grub は当然待ち時間なしにしておく)。

設定は下記

2015-11-23 (4).png

2015-11-23 (5).png

2015-11-23 (6).png

2015-11-23 (7).png

2015-11-23 (8).png

2015-11-23 (9).png

2015-11-23 (10).png

あとは普通に jessie インストールする。初期導入するのは sshd だけでよい。
2015-11-23 (12).png

導入後にホストオンリーアダプタの設定をしておく。

sh
# vi /etc/network/intarefaces
text
allow-hotplug eth1
iface eth1 inet static
  address 192.168.56.101
  gateway 192.168.56.1
  netmask 255.255.255.0

mintty 用にフォントインストール

手元の Windows 機には mintty を導入しておく。手っ取り早く言えば msys git 入れておけということである。

表示用にフォントをインストールする。定番は inconsolataらしい。
うむ、確かに美しい。これに日本語フォントをフォントリンクするのが良い、とのことなので、する。

registry
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink" /v "Inconsolata" /t "REG_MULTI_SZ" /d "MEIRYO.TTC,Meiryo" /f

2015-11-23 (17).png

ちなみに、等幅 Meyryo や Yu Gothic UI をいろいろサイズ指定しながら試したが、後述する tmux で「|」が不可視になるなど難しかった。最終的に素の Meyryo に戻りました。

(2015/11/26 追記)
Meyryo フォントリンクのサイズ指定で何回か再起動したところで心が折れた。Inconsolata +源真ゴシック派生フォントのMyrikaに置き換えた。
tmux などで倍角フォントが崩れる現象は mintty の text 設定で Locale を「ja_JP」以外にすると回避できた。

ssh キー登録

今回の構成では、起動した VirtualBox に ssh ログインすることを企図している。鍵認証方式とするため ssh キーを登録する。

ホスト側で鍵を生成する。

sh
$ ssh-keygen
$ scp .ssh/id_rsa.pub [$user]@192.168.56.101:.ssh/

リモート側で鍵登録する

sh
$ cd .ssh/
$ cat id_rsa.pub >> authorized_keys

以降は、ホスト側でVirtualBox をヘッドレス起動し、ssh 接続する。

sh
 $ /c/Program\ Files/Oracle/VirtualBox/VBoxManage.exe startvm "jessie" --type headless; sleep 20;  ssh -i .ssh/id_rsa 192.168.56.101

環境導入

さて、何はともあれ sudo は入れておく。

sh
# apt-get install -y sudo
# gpasswd -a [$user] sudo

しかるがのち、使用する環境を導入する。設定については dotfiles 参照のこと。導入部分を抜粋する。

base

sh
$ sudo apt-get install -y git zsh vim tmux ctags curl
$ sudo apt-get install -y make binutils bison gcc build-essential
sh
$ sudo chsh -s /bin/zsh [$user]

vim neobundle

sh
% mkdir -p ~/.vim/bundle
% git submodule git://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
% git submodule init
% git submodule update

(2015/11/28 submodule 方式に変更)

vim
:NeoBundleInstall

docker-engine

sh
% sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572c52609d
% echo 'deb https://apt.dockerproject.org/repo debian-jessie main' |sudo tee /etc/apt/sources.list.d/docker.list
% sudo apt-get install -y apt-transport-https
% sudo apt-get update
% apt-cache policy docker-engine
% sudo apt-get install -y docker-engine

haskell stack

sh
% echo 'deb http://download.fpcomplete.com/debian/jessie stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
% wget -q -O- https://s3.amazonaws.com/download.fpcomplete.com/debian/fpco.key | sudo apt-key add -
% sudo apt-get update
% sudo apt-get install -y stack

node nodebrew

sh
% curl -L git.io/nodebrew | perl - setup
% echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> .zshrc
% source .zshrc
% nodebrew install-binary stable
% nodebrew use stable

golang goberw

sh
% curl -L https://raw.github.com/grobins2/gobrew/master/tools/install.sh | sh
% source .zshrc
% gobrew install 1.5.1
% gobrew use 1.5.1
15
13
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
15
13