WSL → Linuxbrew → fish → fisher → VSCode

[https://brew.sh/2019/02/02/homebrew-2.0.0/](https://brew.sh/2019/02/02/homebrew-2.0.0/)

LinuxbrewがWSLで正式サポートYATTA! YATTA!

ということでWSLの開発環境構築をリニューアルするいい機会なので備忘をば。

最終目標はVSCodeのターミナルでWSL::fishでニンマリ。です。

# WSL

[Windows Subsystem for Linux Installation Guide for Windows 10](https://docs.microsoft.com/ja-jp/windows/wsl/install-win10)

上記手順でUbuntuをインストール後パッケージをアップデート

```bash
$ sudo apt update
$ sudo apt upgrade
```

# Linuxbrew

http://linuxbrew.sh/


```bash
$ sudo apt-get install build-essential curl file git
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
$ echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >> ~/.profile
$ . ~/.profile
```

`brew doctor`を実行してWarningを指示内容に従って解決

```zsh
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don\'t worry or file an issue; just ignore this. Thanks!

Warning: The following directories do not exist:
/home/linuxbrew/.linuxbrew/var/homebrew/linked

You should create these directories and change their ownership to your account.
  sudo mkdir -p /home/linuxbrew/.linuxbrew/var/homebrew/linked
  sudo chown -R $(whoami) /home/linuxbrew/.linuxbrew/var/homebrew/linked

Warning: umask is currently set to 000. Directories created by Homebrew cannot
be world-writable. This issue can be resolved by adding umask 002 to
your ~/.bash_profile
  echo 'umask 002' >> ~/.bash_profile

$ sudo mkdir -p /home/linuxbrew/.linuxbrew/var/homebrew/linked
$ sudo chown -R $(whoami) /home/linuxbrew/.linuxbrew/var/homebrew/linked
$ echo 'umask 002' >> ~/.bash_profile
$ . ~/.bash_profile
$ brew doctor
Your system is ready to brew.
```

# fish

[Friendly interactive shell](https://fishshell.com/)

デフォルトが最高すぎるShell、ものぐさなワタシにピッタリ。

```bash
$ brew install fish
$ sudo sh -c "echo /home/linuxbrew/.linuxbrew/bin/fish >> /etc/shells"
$ chsh -s /home/linuxbrew/.linuxbrew/bin/fish
```

ターミナルを再起動し、LinuxbrewのPathを通します。

```zsh
$ echo 'eval (/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >> ~/.config/fish/config.fish
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don\'t worry or file an issue; just ignore this. Thanks!

Warning: umask is currently set to 000. Directories created by Homebrew cannot
be world-writable. This issue can be resolved by adding umask 002 to
your ~/.config/fish/config.fish
  echo 'umask 002' >> ~/.config/fish/config.fish

$ echo 'umask 002' >> ~/.config/fish/config.fish
$ . ~/.config/fish/config.fish
$ brew doctor
Your system is ready to brew.
```

# fisher
https://github.com/jorgebucaran/fisher

fishのplugin管理ツールです。今回はfishにPowerline-styleを導入します。

```zsh
$ curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish
```

ターミナルを再起動し、テーマをインストール。

```zsh
$ fisher add oh-my-fish/theme-agnoster
```

# VSCode
VSCodeはインストールしてある前提です。

ターミナル用に"Source Code Pro for Powerline"をインストールします。

https://github.com/powerline/fonts

```zsh
# 任意のwindowsのディレクトリにgit clone
$ git clone https://github.com/powerline/fonts
```

エクスプローラでfonts/SourceCodeProを開き、Source Code Pro for Powerline.otfをインストール

VSCodeのsettngs.jsonに以下を記述

```json:settings.json
{
  "terminal.integrated.shell.windows": "C:/WINDOWS/system32/wsl.exe",
  "terminal.integrated.fontFamily": "'Source Code Pro for Powerline'",
}
```

VSCodeのターミナルを再起動して完了です。
![image.png](https://qiita-image-store.s3.amazonaws.com/0/197322/d42612e5-1159-2f57-76cf-1de3dc514679.png)

Linuxbrewで開発環境つくれるようになって嬉しい