🙌

WSL Ubuntu の初期化 / 再設定 手順書

2023/04/29に公開

meta

  • 作成日: 2023.04.29

よく使うコマンド

VM 一覧

wsl -l -v

VM 削除

wsl --unregister Ubuntu

VM 作成

wsl --install -d Ubuntu

ref

https://qiita.com/matsujirushi/items/08e7d3940c5ad35a2462
https://zenn.dev/s_ryuuki/articles/41514a18228c02
https://lazesoftware.com/ja/blog/230206/

Git の基本設定

git config --global user.email "kuzumotch@gmail.com"
git config --global user.name "kuzumotch"

promptの変更

vi ~/.bashrc
PS1のところは、差し替え。ほかは.bashrcに追記
    PS1='\e[35m\t | \e[34m\w |$(__git_ps1) \e[0m\$ '

GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUPSTREAM=auto

ref

https://zenn.dev/kcabo/articles/555d9cc6dad0c3
https://tm.root-n.com/unix:command:git:bash_prompt


1Password ssh-agent機能のための設定

sudo apt update
sudo apt install socat
sudo apt install unzip
curl -L -O https://github.com/jstarks/npiperelay/releases/download/v0.1.0/npiperelay_windows_amd64.zip
unzip  npiperelay_windows_amd64.zip
sudo mv npiperelay.exe /usr/local/bin
rm npiperelay_windows_amd64.zip
以下を.bashrcに追記
# Configure ssh forwarding
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
# need `ps -ww` to get non-truncated command for matching
# use square brackets to generate a regex match for the process we want but that doesn't match the grep command running it!
ALREADY_RUNNING=$(ps -auxww | grep -q "[n]piperelay.exe -ei -s //./pipe/openssh-ssh-agent"; echo $?)
if [[ $ALREADY_RUNNING != "0" ]]; then
    if [[ -S $SSH_AUTH_SOCK ]]; then
        # not expecting the socket to exist as the forwarding command isn't running (http://www.tldp.org/LDP/abs/html/fto.html)
        echo "removing previous socket..."
        rm $SSH_AUTH_SOCK
    fi
    echo "Starting SSH-Agent relay..."
    # setsid to force new session to keep running
    # set socat to listen on $SSH_AUTH_SOCK and forward to npiperelay which then forwards to openssh-ssh-agent on windows
    (setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork &) >/dev/null 2>&1
fi

ref

https://qiita.com/mfunaki/items/db6e1ffcf1e6f1eff252 >> ~/.bashrc
https://level69.net/archives/31056 >> ~/.bashrc


fish-shell install

ref

https://qiita.com/koji9412/items/7e2a15c330c387fc5b3b
https://tech.ateruimashin.com/2021/03/wsl2_fish_shell/
https://github.com/miiton/Cica/releases/tag/v5.0.3

cicaフォント最新版がv5.0.3なこといることに注意


Discussion