目次

SetUp

WSLインストール

Windowsターミナルのインストール

Windowsターミナルのセットアップ

スタートアップの設定

プロファイルごとの設定

ディレクトリの開始の設定

パッケージの更新

$ sudo apt -y update
$ sudo apt -y upgrade

日本語化する

$ sudo apt -y install language-pack-ja

SSHの設定

ディレクトリの作成

# ディレクトリの作成
$ mkdir ~/.ssh

# パーミッションの変更
$ chmod 700 ~/.ssh

configファイルの作成

ServerAliveInterval 60

Host github github.com
        HostName github.com
        User git
        IdentityFile /home/(ユーザ名)/.ssh/github/id_rsa

疎通確認

$ ssh -T github
Hi (ユーザ名)! You've successfully authenticated, but GitHub does not provide shell access.

SSH-AGENT

if [ -z "$SSH_AUTH_SOCK" ]; then
   # Check for a currently running instance of the agent
   RUNNING_AGENT="`ps -ax | grep 'ssh-agent -s' | grep -v grep | wc -l | tr -d '[:space:]'`"
   if [ "$RUNNING_AGENT" = "0" ]; then
        # Launch a new instance of the agent
        ssh-agent -s &> .ssh/ssh-agent
   fi
   eval `cat $HOME/.ssh/ssh-agent`
fi

ssh-add $HOME/.ssh/github/id_rsa

socat

Gitの設定

# 名前とメールの設定
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"

# 自動改行変換の無効化
$ git config --global core.autoCRLF false
# パーミッション変更の無効化(initやcloneの都度実行)
$ git config core.filemode false

ブランチ名の表示

export PS1='\[\033[01;32m\]\u@\h\[\033[01;33m\] \w \[\033[01;31m\]$(__git_ps1 "(%s)") \n\[\033[01;34m\]\$\[\033[00m\] '

参考

1)
『WSL2のUbuntu 20.04を日本語化する』, Qiita, https://qiita.com/myalpine/items/fb45b222924b2e61ea9f, 2021-10-15
2)
『Visual Studio Code Remote Development Troubleshooting Tips and Tricks』, Visual Studio Code, https://code.visualstudio.com/docs/remote/troubleshooting, 2021-10-15
3)
『Bash: .bashrcと.bash_profileの違いを今度こそ理解する』, TechRacho by BPS株式会社, https://techracho.bpsinc.jp/hachi8833/2021_07_08/66396, 2021-10-15
4)
『混沌を極めるWindowsのssh-agent事情』, Qiita, https://qiita.com/slotport/items/e1d5a5dbd3aa7c6a2a24, 2021-10-18