Zsh :: oh-my-zsh

Published onesixx on


Zsh 설치 이유

  • a shell designed for interactive use, although it is also a powerful scripting language.
  • 맥 iTerm, Ubuntu 터미널 앱 같은 환경으로 맞추기 위해 ..

현재 환경

### 현재 Shell 확인
$ echo $0
$ echo $SHELL

### 현재 Shell 위치 
$ which zsh                                                                     ✔ │ base 

### 버전 확인
$ zsh --version                                                                 ✔ │ base 
zsh 5.8 (x86_64-apple-darwin20.0)

$ ls -al ~ | grep .z                                                            ✔ │ base 
drwxr-xr-x  21 onesixx  staff    672 Sep 11 22:11 .oh-my-zsh
-rw-r--r--   1 onesixx  staff  85717 Sep 13 16:05 .p10k.zsh
-rw-r--r--   1 onesixx  staff  48094 Sep 13 16:15 .zcompdump-sixxCC-5.8
-rw-------   1 onesixx  staff  15140 Sep 16 12:35 .zsh_history
drwx------  23 onesixx  staff    736 Sep 15 23:33 .zsh_sessions
-rw-r--r--   1 onesixx  staff   4842 Sep 13 16:12 .zshrc

# 기본 sh 변경
chsh -s $(which zsh)

Zsh 설정 파일 로딩 순서 

  /etc/zsh/zshenv  –> /etc/zsh/zprofile   –>  /etc/zsh/zshrc    –>  /etc/zsh/zlogin

~/.zshenv  –> ~/.zprofile  –> ~/.zlogin –> ~/.zshrc


Since .zshenv is always sourced, it often contains exported variables that should be available to other programs.
For example, $PATH, $EDITOR, and $PAGER are often set in .zshenv.
Also, you can set $ZDOTDIR in .zshenv to specify an alternative location for the rest of your zsh configuration.


is for interactive shell configuration. You set options for the interactive shell there with the setopt and unsetopt commands. You can also load shell modules, set your history options, change your prompt, set up zle and completion, et cetera. You also set any variables that are only used in the interactive shell (e.g. $LS_COLORS).


is sourced on the start of a login shell. This file is often used to start X using startx.
Some systems start X on boot, so this file is not always very useful.
.zlogin is sourced after .zshrc


is basically the same as .zlogin except that it’s sourced directly before .zshrc is sourced instead of directly after it.
According to the zsh documentation, “.zprofile is meant as an alternative to `.zlogin’ for ksh fans; the two are not intended to be used together, although this could certainly be done if desired.”


is sometimes used to clear and reset the terminal.
You should go through the configuration files of random Github users to get a better idea of what each file should contain.



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


https://github.com/robbyrussell/oh-my-zsh/wiki/Themes 에 여러 테마를 고를수 있다. 

Powerlevel10k (Oh My Zsh에 적용 가능한 테마중 하나)


$ git clone https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
$ source ~/powerlevel10k/powerlevel10k.zsh-theme
$ p10k configure

잘못 선택했다면 p10k.zsh 라는 파일을 지우면 다시 설정할 수 있게 해준다.

Enabling Plugins

Plugins을 설치하면서 추가기능 사용 (~/.oh-my-zsh/plugins/*)

vi /.zshrc


plugins=(git sublime)

Using Plugins

Most plugins (should! we’re working on this) include a README, which documents how to use them.


cd …. 부모의 부모 디렉토리로 이동

cd –     이전 히스토리 .

oh-my-zsh 플러그인

0. oh-my-zsh의  기본 플러그인

1. 명령어 하이라이팅 플러그인 – zsh-syntax-highlighting

# 설치
brew install zsh-syntax-highlighting

# 적용
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

# .zshrc에 추가 (항상 실행 설정)
위 내용을 ~/.zshrc 맨아래 추가 

2. 자동완성 플러그인 –  zsh-autosuggestions

 suggestion이 나오면 방향키 오른쪽 을 이용하면 자동 완성이 됩

# 설치
$ brew install fzf

#To install useful keybindings and fuzzy completion:
$ /usr/local/opt/fzf/install

# 적용
$ source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh

# .zshrc에 추가 (항상 실행 설정)
위 내용을 ~/.zshrc 맨아래 추가 

3. Commandline fuzzy finder 플러그인 –  fzf

기본적인 기능

# 설치
brew install zsh-autosuggestions

# 적용
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh

# 파이프라인을 이용하는 방법
find * -type f | fzf > selected


paste 에러


~/.zshrc에 ADD

# Code from Mikael Magnusson: http://www.zsh.org/mla/users/2011/msg00367.html
# Requires xterm, urxvt, iTerm2 or any other terminal that supports bracketed
# paste mode as documented: http://www.xfree86.org/current/ctlseqs.html

# create a new keymap to use while pasting
bindkey -N paste
# make everything in this keymap call our custom widget
bindkey -R -M paste "^@"-"\M-^?" paste-insert
# these are the codes sent around the pasted text in bracketed
# paste mode.
# do the first one with both -M viins and -M vicmd in vi mode
bindkey '^[[200~' _start_paste
bindkey -M paste '^[[201~' _end_paste
# insert newlines rather than carriage returns when pasting newlines
bindkey -M paste -s '^M' '^J'

zle -N _start_paste
zle -N _end_paste
zle -N zle-line-init _zle_line_init
zle -N zle-line-finish _zle_line_finish
zle -N paste-insert _paste_insert

# switch the active keymap to paste mode
function _start_paste() {
  bindkey -A paste main

# go back to our normal keymap, and insert all the pasted text in the
# command line. this has the nice effect of making the whole paste be
# a single undo/redo event.
function _end_paste() {
#use bindkey -v here with vi mode probably. maybe you want to track
#if you were in ins or cmd mode and restore the right one.
  bindkey -e
  unset _paste_content

function _paste_insert() {

function _zle_line_init() {
  # Tell terminal to send escape codes around pastes.
  [[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004h'

function _zle_line_finish() {
  # Tell it to stop when we leave zle, so pasting in other programs
  # doesn't get the ^[[200~ codes around the pasted text.
  [[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004l'

Categories: Ubuntu


Blog Owner

Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x