# zsh and  oh-my-zsh

{% hint style="info" %}
zsh는 linux 기반 OS에서만 설치가 가능합니다. Windows 사용자는 Cloud9과 같은 환경을 통해 설정을 진행해주시기 바랍니다!
{% endhint %}

## zsh 및 oh-my-zsh 설치

테라폼 작업은 주로 bash shell에서 진행됩니다. 따라서 bash를 조금이라도 편리하게 사용하는 것이 작업 속도를 높일 수 있는 방법입니다.

본 장에서는 bash 대신 사용할 zsh(z-shell) 과 oh-my-zsh 설정에 대해서 알아보겠습니다.&#x20;

### Linux 환경&#x20;

```bash
### Cloud9 환경에서 su 명령을 이용해 bash 로 변경. 유저는 선택사항입니다.
ec2-user:~/environment $ sudo -i
[root@ip-172-31-8-195]~# su - ec2-user
[ec2-user@ip-172-31-8-195]~% 

### zsh 설치
[ec2-user@ip-172-31-8-195]~% sudo yum install zsh         
Complete!

### ec2-user password 설정.
[ec2-user@ip-172-31-8-195]~% sudo -i
[root@ip-172-31-8-195 ~]# passwd ec2-user   
...
passwd: all authentication tokens updated successfully.

### bash 에서 zsh 로 shell 변경
[root@ip-172-31-8-195 ~]# exit
logout
[ec2-user@ip-172-31-8-195]~% $ which zsh
/bin/zsh
[ec2-user@ip-172-31-8-195]~% $ chsh -s /bin/zsh
Changing shell for ec2-user.
Password: 
Shell changed.
[ec2-user@ip-172-31-8-195]~% echo $SHELL  ### shell 변경 확인.
/bin/zsh

### Oh my zsh 설치
[ec2-user@ip-172-31-8-195]~% curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh                                                                                                                                                                                                        
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  8445  100  8445    0     0  12776      0 --:--:-- --:--:-- --:--:-- 37202
.....
         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/                       ....is now installed!

Please look over the ~/.zshrc file to select plugins, themes, and options.
p.s. Follow us on https://twitter.com/ohmyzsh
p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh
Run zsh to try it out.
```

oh my zsh 의 테마 는 개인 선호도에 따라 선택하면 되지만,&#x20;

적절한 컬러, Git branch, commit 확인이 되는 테마를 고르는게 좋습니다. 저는 ys 를 선호합니다.

```bash
[ec2-user@ip-172-31-8-195]~% sudo vim ~/.zshrc

### in ~/.zshrc
ZSH_THEME="ys" ## THEME 변경 후 터미널 재실행
# ec2-user @ ip-172-31-8-195 in ~ [19:43:14] 
 
### 터미널 재실행

###  ~/.oh-my-zsh/lib/key-bindings.zsh 에서  echoti smkx 주석처리
###  해당 부분을 주석처리 하지 아니하면, 스크롤이 오동작하는 버그가 있습니다.
```

### Mac 환경

Mac 환경에서 zsh을 설치할 때는 brew를 사용하시면 편리합니다.

```
# install brew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# install zsh
$ brew install zsh

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

oh-my-zsh 설정의 위와 동일합니다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://terraform201.devart.tv/0.-terraform-intermediate/zsh-and-oh-my-zsh.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
