LoginSignup
24
22

More than 5 years have passed since last update.

Bash on Windows で powerline を使うまで

Last updated at Posted at 2016-08-04

環境

Windows 10 Build 14393

インストール

  1. Winマークを右クリック>プログラムと機能>Windows の機能の有効化または無効化>Windows Subsystem for Linux (Beta) にチェック
  2. 設定>開発者向け>開発者モード
  3. 再起動
  4. コマンドプロンプトを開き bash でインストールが始まる
  5. UNIXユーザー名とパスワードを求められるので入力してインストール完了

セットアップ

sudo apt-get update
sudo apt-get upgrade

途中sudo: unable to resolve hostと表示されるのでホストを追加してやる

sudo sh -c 'echo 127.0.1.1 $(hostname) >> /etc/hosts'

各種インストール

zsh

必須じゃないけどなれたらbashに戻れないので

sudo apt-get install zsh

次回起動時にzshが実行されるようにする

chsh/etc/passwdを変更してもbashで立ち上がるので以下のようにする。
1. #mv /bin/bash /bin/.bashでbashのバイナリを退避させる
2. 以下のシェルスクリプトを/bin/bashとして保存
3. #chmod 755 /bin/bashで実行可能な状態にする

/bin/bash
#!/bin/sh
export SHELL=/bin/zsh
exec $SHELL
exit 

Git

sudo apt-get install git

powerline

sudo apt-get install python-pip
sudo pip install --user git+git://github.com/powerline/powerline

パスを通す

.zshrc
export PATH=$PATH:~/.local/bin/

zshで使う

.zshrc
powerline-daemon -q
. ~/.local/lib/python2.7/site-packages/powerline/bindings/zsh/powerline.zsh

powerline用のフォントのインストール

powerline/fonts/
https://github.com/powerline/fonts/
~/.fontsに入れても使えないので各.ttfをダウンロードしてインストールしてコンソールから指定する

代替コンソールを使う

コマンドプロンプトだとフォントを変えても再起動するとMSゴシックになってるのでConEmuを使う
ConEmu
https://conemu.github.io/

  1. 初回起動時に設定画面が出るのでBashを選択する
  2. Setting>Main>Main console font をさっき入れたフォントにする

再インストール

なんかやらかした時用

cmd.exe
lxrun /uninstall
lxrun /install

エラーが出てインストール出来ないので再起動してから再度 lxrun /installする

参考

Error reinstalling bash - Error 0x80070005
https://github.com/Microsoft/BashOnWindows/issues/473#issuecomment-224708711
Bash on Ubuntu on Windowsのアンインストール・インストール方法はどうしたらいいのか?
http://blog.sfpgmr.net/entry/2016/04/09/142344
sudo: unable to resolve host が表示されたら
http://qiita.com/ogomr/items/89e19829eb8cc08fcebb
Ubuntu on Windows で zshをデフォルトシェルにする
http://qiita.com/nsmr0604@github/items/7dd38faed1abd9189a83

24
22
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
24
22