운영체제/MAC

[Mac] oh my zsh설치

louky 2021. 6. 9. 15:09
반응형

bash shell를 선호하지만 zshell 환경이 필요하여 설치하게 되었다. 

 

환경 : macOS Big Sur (11.3)
모델 : MacBook Pro 13-inch, 2018

 

oh-my-zsh install 

Usage)

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
user % sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"


Cloning Oh My Zsh...
'/Users/hnsong/.oh-my-zsh'에 복제합니다...
remote: Enumerating objects: 1210, done.
remote: Counting objects: 100% (1210/1210), done.
remote: Compressing objects: 100% (1175/1175), done.
remote: Total 1210 (delta 20), reused 1095 (delta 15), pack-reused 0
오브젝트를 받는 중: 100% (1210/1210), 844.24 KiB | 4.29 MiB/s, 완료.
델타를 알아내는 중: 100% (20/20), 완료.

Looking for an existing zsh config...
Using the Oh My Zsh template file and adding it to ~/.zshrc.

Time to change your default shell to zsh:
Do you want to change your default shell to zsh? [Y/n]  y
Changing the shell...
Changing shell for user_name.
Password for user_name:
Shell successfully changed to '/bin/zsh'.

         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/                       ....is now installed!


Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.

• Follow us on Twitter: https://twitter.com/ohmyzsh
• Join our Discord server: https://discord.gg/ohmyzsh
• Get stickers, shirts, coffee mugs and other swag: https://shop.planetargon.com/collections/oh-my-zsh

[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxr-x  3 hnsong  admin   96  1  5 18:35 /usr/local/share/zsh
drwxrwxr-x  5 hnsong  admin  160  2  9 16:03 /usr/local/share/zsh/site-functions

[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.

[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh]     compaudit | xargs chmod g-w,o-w

[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.

 

사용하고자 하는  theme가 있을 경우 해당 theme 로 진행하면 되고 필자의 경우 decula theme를 선호하기에 dracula theme를 먼저 설치 후 .zshrc에 반영 하였다. 

 

dracula theme  설치 

~ git clone https://github.com/dracula/zsh.git

~ cd zsh 

~ ln -s dracula.zsh-theme /.oh-my-zsh/themes/dracula.zsh-theme

 

 

~/.zshrc 수정

> vi .zshrc

~(생략)

#ZSH_THEME="robbyrussell"    ###  기존  ZSH_THEME를 주석 처리
ZSH_THEME="dracula"         ### 또는 "robbyrussell" -> "dracula" 로 변경

### Prompt 수정 
prompt_context() { 
  if [[ “$USER” != “$DEFAULT_USER” || -n “$SSH_CLIENT” ]]; then 
      prompt_segment black default “%(!.%{%F{yellow}%}.)$USER” 
  fi
}

 

자동완성 기능을 사용하고자 할 경우 별도의 plugin을 설치 한다. 

여기서는 oh my zsh를 이용한 설치 방법이다. 

> cd ~/.oh-my-zsh/plugins

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

 

~ cd ~/.oh-my-zsh/plugins
➜ plugins (master) ✗ git clone https://github.com/zsh-users/zsh-autosuggestions \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions


'/Users/USER_NAME/.oh-my-zsh/custom/plugins/zsh-autosuggestions'에 복제합니다...
remote: Enumerating objects: 2435, done.
remote: Counting objects: 100% (50/50), done.
remote: Compressing objects: 100% (40/40), done.
remote: Total 2435 (delta 21), reused 22 (delta 9), pack-reused 2385
오브젝트를 받는 중: 100% (2435/2435), 566.34 KiB | 6.91 MiB/s, 완료.
델타를 알아내는 중: 100% (1552/1552), 완료.
➜ plugins (master) ✗

~/.zshrc에 "zsh-autosuggestions"를 plugin으로 추가 

~ echo "plugins=(zsh-autosuggestions)" >> ~/.zshrc
~ source ~/.zshrc

 

Update - 2023/01/05

- Uninstall

source ~/.oh-my-zsh/tools/uninstall.sh

 

반응형