small is beautiful.

If you haven't had any obstacles lately, you're not challenging. be the worst.

Setup ThinkPad T480s

当該端末や環境に依存しない記述も多とありますがご容赦ください.

Env

OS 名:                  Microsoft Windows 10 Pro
OS バージョン:          10.0.18362 N/A ビルド 18362
プロセッサ:             1 プロセッサインストール済みです.
                        [01]: Intel64 Family 6 Model 142 Stepping 10 GenuineIntel ~1910 Mhz
BIOS バージョン:        LENOVO N22ET60W (1.37 ), 2019/11/25
物理メモリの合計:       24,410 MB
仮想メモリ: 最大サイズ: 33,626 MB

WSL

WSL activate

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

drvfs meta を付与して c mount

sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata

wsl.conf に追記して自動 mount されるようにする

[automount]
enabled = true
root = /mnt/
options = "metadata"
mountFsTab = true

[network]
generateHosts = true
generateResolvConf = true

[interop]
enabled = true
appendWindowsPath = true

Install some packages on Ubuntu OS.

# package update & upgrade
sudo apt update
sudo apt upgrade
# Remove package is no longer required
sudo apt autoremove

# Add repository ubuntui-ja[jp]
wget -q https://www.ubuntulinux.jp/ubuntu-ja-archive-keyring.gpg -O- | sudo apt-key add -
wget -q https://www.ubuntulinux.jp/ubuntu-jp-ppa-keyring.gpg -O- | sudo apt-key add -

# Add locale jp
sudo apt install -y language-pack-ja
sudo update-locale LANG=ja_JP.UTF-8

sudo apt install kpcli
sudo apt install jpegoptim
sudo apt install make
sudo apt install lv
sudo apt install unzip

## vim
sudo apt install vim-nox

## Git client
sudo dpkg --configurfe -a
sudo apt install git

### uninstall nano editor
sudo dpkg -P nano

mkdir ~/.ssh && chmod 0600 ~/.ssh

# tmux
sudo apt install tmux

# zsh completions
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/shells:/zsh-users:/zsh-completions/xUbuntu_19.10/ /' > /etc/apt/sources.list.d/shells:zsh-users:zsh-completions.list"
wget -nv https://download.opensuse.org/repositories/shells:zsh-users:zsh-completions/xUbuntu_19.10/Release.key -O Release.key
sudo apt-key add - < Release.key
sudo apt-get update
sudo apt-get install zsh-completions

# Neovim
sudo apt install software-properties-common
sudo apt install python-software-properties
sudo apt-add-repository ppa:neovim-ppa/stable
sudo apt install neovim

# Python3
sudo apt install python3-pip
pip3 install --upgrade pip
pip3 install --user pipenv

# pyenv
git clone https://github.com/yyuu/pyenv.git ~/.pyenv # for python3.7.1
vim ~/.zshrc
# export PYENV_ROOT="$HOME/.pyenv"
# export PATH="$PYENV_ROOT/bin:$PATH"
# eval "$(pyenv init -)"

sudo apt install libffi-dev # *1.
pyenv install 3.7.1
pipenv install -d --python=$HOME/.pyenv/versions/3.7.1/bin/python # *2.

# if you want to reset wsl, execute as below.
lxrun /uninstall /full
lxrun /install

Install Applications

  • 7zip
  • screenpresso
    • screen capture
  • clibor
    • copy history
  • keypirinha (Mac spotlight 風)
    • Launcher, Calculator
    • 展開するのに 7zip が必要
  • hyper
    • terminal
  • Alt-Tab Terminator
    • task swither

keypirinha の setting

[app]
launch_at_startup = yes
hotkey_run = Ctrl+Space
hotkey_history = Ctrl+Shift+Space
show_on_taskbar = no

[gui]
hide_on_focus_lost = yes
theme = TinyLayout, SolarizedDarkColors
auto_width = 20
max_results = 200

hyper 起動時に wsl.exe が起動するように変更.

    shell: 'C:\\Windows\\System32\\wsl.exe',
    shellArgs: ['~'],

VS Code

  • Extension: Settings Sync で GitHub へログインし token から設定を復元する.

PowerShell

(可能な限り PowerShell は触りたくない.)

# install chocolatey (require reboot)
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

# install theme this affect WSL
choco install microsoft-windows-terminal

# Key bind

## change `CapsLock` to `Control` key

$hexified = "00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00".Split(',') | % { "0x$_"};
$kbLayout = 'HKLM:\System\CurrentControlSet\Control\Keyboard Layout';
New-ItemProperty -Path $kbLayout -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$hexified);

Git

WSL 上から ssh-add 出来ず, eval が必要だった.

sudo ssh-add ~/.ssh/id_rsa
Could not open a connection to your authentication agent.

eval `ssh-agent`
ssh-add ~/.ssh/id_rsa

git clone 

Trouble shooting

Mac から backup していた幾つかの file が binary file として認識される

WSL 上から何故か (MacBook Pro で backup していた) Dropbox 配下のファイルが binary として認識される.

hexdump -C .zshrc | head
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000039c3

file -bi .zshrc
application/octet-stream; charset=binary

# 変換を試みるも意味無し
iconv -f utf-8 -t utf-8 -o .zhshr .zshrc
cat .zshrc | tr -d '\0' > .zshrc
nkf -w .zshrc > .zshrc

Google Drive は問題無かったので, 仕方なく Google Drive 経由で同期するように変更した.

※ Box は同期に数分掛かる場合があり遅すぎる..WSL 上から Box のパスが直ぐには分からず.

libyajl2 の gem install でエラー

sudo gem install  libyajl2 -v '1.2.0' 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
sudo apt-get install ruby-dev

ruby-dev をインストールする必要があった.

bundle install でエラー

sudo /usr/local/bin/bundle install
Traceback (most recent call last):                                                                                                                                                                   2: from /usr/local/bin/bundle:23:in `<main>'                                                                                                                                                 1: from /usr/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'                                                                                                                   /usr/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

sudo gem update --system もしくは gem install bundler -v 1.6.1 のようにバージョン指定してあげる必要があった.


Notes

*1.

そのまま pyenv install 3.7.1 を実行すると module not found となる.

ModuleNotFoundError: No module named '_ctypes'
Makefile:1122: recipe for target 'install' failed

*2.

pipenv --three --python=which python3` とかだと local default の python3.6.8 が入ってしまった.