본문 바로가기
OS

WSL2에서 Ubuntu zsh 설치 및 각종 팁

by Natekwon 2021. 1. 24.

WSL 우분투에서 zsh유저들을 위한 설치 및 에러 해결 팁입니다. 설치는 차례대로 실행해주면 됩니다.

 

sudo apt-get install zsh

 

chsh -s /usr/bin/zsh

 

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

 

sudo apt install fonts-powerline

 

<<plugin install>>

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

 

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

 

sudo gedit ~/.zshrc 

 

<수정>

-> THEME=”agnoster”

-> plugins=(git zsh-syntax-highlighting zsh-autosuggestions)

 

 

근데 WSL에서는 폰트를 다운 받아도 글자 깨짐이 제대로 해결이 안되는 경우가 있습니다.

https://mong9data.tistory.com/113

여기의 해결법으로 폰트 설치를 하면 깔끔하게 해결이 됩니다.

 

그리고 폰트 설치이후 터미널 창의 속성에서 글꼴을 설치된 MesloLGS NF로 설정하면 깨짐이 해결됩니다.

 

또한 WSL 사용시 복사 붙여넣기는 마우스 우클릭으로 실행됩니다.

 

 

추가

 

<xserver install>

리눅스 GUI를 윈도우에서 실행하기 위해서 해당 프로그램 설치 및 실행이 필요하다.

 

sourceforge.net/projects/vcxsrv/files/latest/download

실행 시

Display number -> 0

WSL2 는 Native opengl 체크해제

Additional parameters -> -ac

 

save configuration 한 config파일을 시작프로그램폴더에 넣어주기!

윈도우 + R -> shell:startup

컴퓨터 켜질때 xserver가 해당 설정으로 자동 실행됨

 

zshrc나 bashrc에 밑의 코드를 추가

export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"

 

이후에 windows terminal에서 우분투를 종료시켜 주면 됩니다

wsl -t Ubuntu-18.04

 

이후 다시 우분투 실행시 작동!

 

 

<긴 유저 네임과 컴퓨터 이름이 보기 싫다면>

zshrc에 다음 코드를 추가

[다 지우기]

export DEFAULT_USER="$(whoami)"

 

[user 이름만 남기기]

prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
  fi
}

 

 

<catkin_make 설정>

gedit ~/.zshrc

source ~/catkin_ws/devel/setup.zsh

source /opt/ros/melodic/setup.zsh