๐Ÿ’ค WSL์˜ Zsh

4244 ๋‹จ์–ด wslbeginnerszshwindows
Z ์…ธ์€ ๊ธฐ๋ณธ Linux ์„ค์น˜์— ์žˆ๋Š” ํ‘œ์ค€ BASH ์…ธ๊ณผ ๊ฑฐ์˜ ๋™์ผํ•˜๊ฒŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ์ ์€ ์ฒ ์ž ์ˆ˜์ • ๋ฐ ์žฌ๊ท€ ๊ฒฝ๋กœ ํ™•์žฅ๊ณผ ๊ฐ™์€ ๋ช‡ ๊ฐ€์ง€ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ๊ณผ ํ•จ๊ป˜ ํ”Œ๋Ÿฌ๊ทธ์ธ ๋ฐ ํ…Œ๋งˆ์— ๋Œ€ํ•œ ์ง€์›์ž…๋‹ˆ๋‹ค. BASH๋ฅผ ์“ฐ๋ ˆ๊ธฐํ†ต์— ๋ฒ„๋ฆด ๋•Œ์ž…๋‹ˆ๋‹ค!

โœ… ์ „์ œ ์กฐ๊ฑด


  • Windows 10 ๋˜๋Š” 11
  • WSL ๋˜๋Š” WSL2

  • ์‚ฌ์šฉ๋˜๋Š” ํ„ฐ๋ฏธ๋„ ๋ช…๋ น์€ Ubuntu/Debian ๊ธฐ๋ฐ˜ Linux ๋ฐฐํฌํŒ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค.


    ๐Ÿš Zsh ์„ค์น˜ํ•˜๊ธฐ



    Zsh๋Š” ํ•˜๋‚˜์˜ ๋ช…๋ น์œผ๋กœ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    sudo apt install zsh
    


    ์„ค์น˜ ํ›„ zsh ๋ช…๋ น์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. Zsh๋Š” ๋ช‡ ๊ฐ€์ง€ ๊ตฌ์„ฑ์„ ์„ ํƒํ•˜๋„๋ก ์š”์ฒญํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋‚˜์ค‘์— oh-my-zsh๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋™์•ˆ ์ด ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ๊ฒƒ์ด๋ฏ€๋กœ ์˜ต์…˜0์„ ์„ ํƒํ•˜์—ฌ ๊ตฌ์„ฑ ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ  ์ด ๋ฉ”์‹œ์ง€๊ฐ€ ๋‹ค์‹œ ํ‘œ์‹œ๋˜์ง€ ์•Š๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.


    ๐Ÿ˜ฑ OhMyZsh



    ์ง€๊ธˆ๊นŒ์ง€ ๊ฐ€์žฅ ์ธ๊ธฐ ์žˆ๋Š” ํ”Œ๋Ÿฌ๊ทธ์ธ ํ”„๋ ˆ์ž„์›Œํฌ๋Š” OhMyZsh ์ž…๋‹ˆ๋‹ค. ์ˆ˜๋งŽ์€ ํ”Œ๋Ÿฌ๊ทธ์ธ, ํ…Œ๋งˆ, ๋„์šฐ๋ฏธ ๋“ฑ์ด ๋ฏธ๋ฆฌ ๋กœ๋“œ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ํ™•์‹คํžˆ ์ƒ์‚ฐ์„ฑ์— ๋„์›€์ด ๋  ์ˆ˜ ์žˆ์ง€๋งŒ ๋” ์ค‘์š”ํ•œ ๊ฒƒ์€ ๋ฉ‹์ ธ ๋ณด์ธ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค ๐Ÿ˜Ž.

    ๊ณฑ์Šฌ ๊ณฑ์Šฌํ•˜๋‹ค



    ๋จผ์ € cURL์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. "ํด๋ผ์ด์–ธํŠธ URL"์˜ ์ค„์ž„๋ง๋กœ ๋ช…๋ น์ค„์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋ฉฐ ์ด๊ฒƒ์ด ์šฐ๋ฆฌ๊ฐ€ OhMyZsh๋ฅผ ๋‹ค์šด๋กœ๋“œํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

    sudo apt install curl
    


    OhMyZsh ์„ค์น˜



    ํ„ฐ๋ฏธ๋„์— ๋‹ค์Œ ๋ช…๋ น์„ ์ž…๋ ฅํ•˜์—ฌ OhMyZsh๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

    sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    


    ๊ทธ๊ฒŒ ๋‹ค์•ผ! ์ด์ œ ํ™ˆ ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด์— .oh-my-zsh ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ํ”Œ๋Ÿฌ๊ทธ์ธ๊ณผ ํ…Œ๋งˆ๋ฅผ ๋ณ€๊ฒฝํ•˜๋ ค๋ฉด ํ™ˆ ๋””๋ ‰ํ† ๋ฆฌ์—๋„ ์žˆ๋Š” .zshrc ํŒŒ์ผ์„ ํŽธ์ง‘ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

    ๋‹ค์Œ์€ OhMyZsh์™€ ํ•จ๊ป˜ ์ œ๊ณต๋˜๋Š” ๋ชจ๋“  themes ๋ฐ plugins์˜ ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค.


    ๐Ÿ”Œ ํ”Œ๋Ÿฌ๊ทธ์ธ



    ์ˆ˜๋งŽ์€ ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์ง€๋งŒ ์ œ๊ฐ€ ๊ฐ€์žฅ ์ถ”์ฒœํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ํ”Œ๋Ÿฌ๊ทธ์ธ์ž…๋‹ˆ๋‹ค.

    zsh-์ž๋™ ์ œ์•ˆ



    zsh์— ๋Œ€ํ•œ ์ž๋™ ์ œ์•ˆ, ๊ธฐ๋ก ๋ฐ ์™„๋ฃŒ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ž…๋ ฅํ•  ๋•Œ ๋ช…๋ น์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค.
  • 1. ์ด ์ €์žฅ์†Œ๋ฅผ $ZSH_CUSTOM/plugins์— ๋ณต์ œํ•ฉ๋‹ˆ๋‹ค(๊ธฐ๋ณธ์ ์œผ๋กœ ~/.oh-my-zsh/custom/plugins )

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


  • 2. Oh My Zsh๊ฐ€ ๋กœ๋“œํ•  ํ”Œ๋Ÿฌ๊ทธ์ธ ๋ชฉ๋ก์— ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค(~/.zshrc ๋‚ด๋ถ€):

  • plugins=(git zsh-autosuggestions)
    


  • 3. ์ƒˆ ํ„ฐ๋ฏธ๋„ ์„ธ์…˜์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

  • zsh ๊ตฌ๋ฌธ ๊ฐ•์กฐ



    ์ด ํŒจํ‚ค์ง€๋Š” ์‰˜ zsh์— ๋Œ€ํ•œ ๊ตฌ๋ฌธ ๊ฐ•์กฐ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. zsh ํ”„๋กฌํ”„ํŠธ์—์„œ ๋Œ€ํ™”ํ˜• ํ„ฐ๋ฏธ๋„์— ์ž…๋ ฅํ•˜๋Š” ๋™์•ˆ ๋ช…๋ น์„ ๊ฐ•์กฐ ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๊ธฐ ์ „์— ๊ฒ€ํ† ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋˜๋ฉฐ ํŠนํžˆ ๊ตฌ๋ฌธ ์˜ค๋ฅ˜๋ฅผ ํฌ์ฐฉํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.
  • 1. oh-my-zsh์˜ ํ”Œ๋Ÿฌ๊ทธ์ธ ๋””๋ ‰ํ† ๋ฆฌ์— ์ด ์ €์žฅ์†Œ๋ฅผ ๋ณต์ œํ•ฉ๋‹ˆ๋‹ค.

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


  • 2. ~/.zshrc์—์„œ ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.

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


  • 3. ์ƒˆ ํ„ฐ๋ฏธ๋„ ์„ธ์…˜์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

  • ๋” ๋งŽ์€ ํ”Œ๋Ÿฌ๊ทธ์ธ



    ๋ฐฉ๋Œ€ํ•œ ํ”Œ๋Ÿฌ๊ทธ์ธ ๋ชฉ๋ก์€ awesome zsh plugins repo ์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


    ์ฐธ์กฐ


  • OhMyZsh Wiki
  • Using Zsh in Windows Terminal
  • A User's Guide to the Z-Shell
  • ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ