zsh(Z Shell) 및 oh-my-zsh 설정

avatar
2025.04.18
·
2 min read

학부 때는 M1 맥북의 기본 shell로 설정되어 있는 zsh로 많은 작업을 했었다. 그러나 대학원에 와서 GPU 서버를 사용하려다 보니 기본 shell이 bash로 되어 있었고 zsh에 익숙해진 나에게는 조금 불편했다. 따라서 기본 shell을 zsh로 바꿔보았다. 예전에 기록해두었던 velog 글을 참고했다.

  • zsh 설치

# 설치
sudo apt install zsh
# 버전 확인
zsh --version
  • 리눅스 사용자 기본 shell 변경

# 변경
sudo chsh -s /usr/bin/zsh {사용자 이름}
# 확인
getent passwd {사용자 이름}
echo $SHELL
  • oh-my-zsh(zsh extension으로 보면 됨) 설치 및 powerlevel10k 테마 설정

# oh-my-zsh 설치
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
source ~/.zshrc

# powerlevel10k 설치
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
source ~/.zshrc

# powerlevel10k 설정
p10k configure
source ~/.zshrc
  • zsh 플러그인 설치

# zsh-autosuggestion 설치
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

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

# git, z(디렉토리 이동 shortcut), zsh-autosuggestions, zsh-syntax-highlighting 플러그인 적용
sudo sed -i 's/^plugins=(.*)/plugins=(git z zsh-autosuggestions zsh-syntax-highlighting)/' ~/.zshrc
source ~/.zshrc