티스토리 뷰

1. 설치

Mac의 기본 셸은 bash 이지만 zsh도 기본 설치되어 있다. zsh로 기본 설정을 바꾸려면 다음과 같이 입력하면 된다.

chsh -s $(which zsh)

 

2. Oh My Zsh

zsh 설정을 관리하는 커뮤니티 기반 프레임워크이며 많은 함수, 헬퍼, 플러그인, 테마들을 가지고 있다. 설치를 하려면 curl이나 wget을 이용한다.

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

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

2-1. 테마 선택하기

https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster

 

ohmyzsh/ohmyzsh

🙃 A delightful community-driven (with 1700+ contributors) framework for managing your zsh configuration. Includes 200+ optional plugins (rails, git, OSX, hub, capistrano, brew, ant, php, python, et...

github.com

굉장히 많은 테마가 있는데 agnoster를 많이 사용하는 것 같다.

이런 느낌의 테마이고 앞의 user@hostname 을 없애는 옵션을 ~/.zshrc에서 수정할 수 있다.

# user@hostname 숨김
prompt_context() {}

# user@hostname에서 user만 보이기
prompt_context() {
   if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
     prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
   fi
}

2-2. Autosuggestion Plugin

$ZSH_CUSTOM/plugin 에 레파지토리를 클론한 후 

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

~/.zshrc 에서 plugins을 찾아 zsh-autosuggestions 을 추가한다.

zsh-autosuggestions 추가

셸을 새로 시작하면 명령을 입력할 때 이전 명령을 찾아 제안을 해준다 (나이스)

 

3. 커스텀 alias

자주쓰는 명령어들의 단축키같은 느낌이다. .zshrc에서 추가하면 된다. 

# npm 모듈 설치
alias nis="npm install --save "

# 히스토리 검색
alias hs="history | grep"

# 폴더 생성 및 폴더 안으로 이동
alias mkcd='foo(){ mkdir -p "$1"; cd "$1" }; foo '

# IP 확인
alias myip='curl http://ipecho.net/plain; echo'

예를 들어 express를 설치하겠다 하면 nis express 라고 하면된다.

 

4. iTerms2

iTerms2 는 터미널 도구다. Mac에서 기본으로 제공하는 터미널보다 더 유용한 기능을 많이 제공한다.  

4-1. 화면 분할 

  • Cmd + d => 세로 분할
  • Cmd + Shift + d => 가로 분할
  • Cmd + Opt + arrow => 탭 간 이동
  • Cmd + Shift + Enter => 전체 화면/본래 화면

4-2. 커서 위치 하이라이트

Preferences > Profile > Colors > Color Guide enable

 

 

참고 문헌

https://www.sitepoint.com/zsh-tips-tricks/

 

10 Zsh Tips & Tricks: Configuration, Customization & Usage — SitePoint

Learn how to install zsh, get the most out of the Oh My Zsh framework, configure plugins, and learn a variety of productivity-enhancing zsh techniques.

www.sitepoint.com

https://codeburst.io/7-super-useful-aliases-to-make-your-development-life-easier-fef1ee7f9b73

 

7 Super Useful Aliases to make your development life easier 👨‍💻 👩‍💻

Let’s talk to your machine in your own language

codeburst.io

https://www.iterm2.com/documentation-highlights.html

 

Highlights for New Users - Documentation - iTerm2 - macOS Terminal Replacement

iTerm2 by George Nachman. Website by Matthew Freeman, George Nachman, and James A. Rosen. Website updated and optimized by HexBrain

www.iterm2.com

 

댓글