Zsh :: oh-my-zsh

Published by onesixx on


Zsh 설치 이유

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

현재 환경 확인

사용중인 SHELL 


$ echo $SHELL


$ vi /etc/passwd

해당 USER 라인끝에 /bin/bash확인


$ which bash

SHELL 설정파일 위치

% ls -al ~ 
-rw------- 1 .bash_history
-rw-r--r-- 1 .bash_logout
-rw-r--r-- 1 .bashrc

Zsh 설치

zsh 설치 (Ubuntu)

$ sudo apt-get install zsh
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-66 linux-headers-4.4.0-66-generic linux-headers-4.4.0-67 linux-headers-4.4.0-67-generic linux-headers-4.4.0-70
  linux-headers-4.4.0-70-generic linux-image-4.4.0-66-generic linux-image-4.4.0-67-generic linux-image-4.4.0-70-generic linux-image-extra-4.4.0-66-generic
  linux-image-extra-4.4.0-67-generic linux-image-extra-4.4.0-70-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
Suggested packages:
The following NEW packages will be installed:
  zsh zsh-common
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 3,822 kB of archives.
After this operation, 14.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://kr.archive.ubuntu.com/ubuntu xenial/main amd64 zsh-common all 5.1.1-1ubuntu2 [3,170 kB]
Get:2 http://kr.archive.ubuntu.com/ubuntu xenial/main amd64 zsh amd64 5.1.1-1ubuntu2 [651 kB]
Fetched 3,822 kB in 0s (5,349 kB/s)
Selecting previously unselected package zsh-common.
(Reading database ... 481688 files and directories currently installed.)
Preparing to unpack .../zsh-common_5.1.1-1ubuntu2_all.deb ...
Unpacking zsh-common (5.1.1-1ubuntu2) ...
Selecting previously unselected package zsh.
Preparing to unpack .../zsh_5.1.1-1ubuntu2_amd64.deb ...
Unpacking zsh (5.1.1-1ubuntu2) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up zsh-common (5.1.1-1ubuntu2) ...
Setting up zsh (5.1.1-1ubuntu2) ...
update-alternatives: using /bin/zsh5 to provide /bin/zsh (zsh) in auto mode
update-alternatives: using /bin/zsh5 to provide /bin/rzsh (rzsh) in auto mode
$ sudo apt-get install zsh-syntax-highlighting

zsh 설치 (Mac)

$ brew install zsh zsh-completions

설치후 확인

zsh 버전 확인

$ zsh --version
zsh 5.1.1 (x86_64-ubuntu-linux-gnu)

SHELL 위치 확인

$ which zsh
/usr/bin/zsh -> /etc/alternatives/zsh-usrbin*
/etc/alternatives/zsh-usrbin -> /bin/zsh5*

설치후 환경 적용

기본 SHELL 변경

$ chsh -s $(which zsh)

터미널 겄다 켜기

This is the Z Shell configuration function for new users, zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:
(q)  Quit and do nothing.  The function will be run again next time.
(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.
(1)  Continue to the main menu.
(2)  Populate your ~/.zshrc with the configuration recommended
     by the system administrator and exit (you will need to edit
     the file by hand, if so desired).

--- Type one of the keys in parentheses --- 

“2”을 입력 빈 설정 파일 “.zshrc”을 만듭니다

설정 파일 로딩 순서 

  /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.



cf. Prezto


sudo apt-get install git-core

Oh my zsh 설치

$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Cloning Oh My Zsh...
Cloning into '/Users/onesixx/.oh-my-zsh'...
remote: Counting objects: 831, done.
remote: Compressing objects: 100% (700/700), done.
remote: Total 831 (delta 14), reused 774 (delta 10), pack-reused 0
Receiving objects: 100% (831/831), 567.61 KiB | 286.00 KiB/s, done.
Resolving deltas: 100% (14/14), done.
Checking connectivity... done.
Looking for an existing zsh config...
Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc
Time to change your default shell to zsh!
         __                                     __   
  ____  / /_     ____ ___  __  __   ____  _____/ /_  
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ 
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / 
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  
                        /____/                       ....is now installed!

Please look over the ~/.zshrc file to select plugins, themes, and options.
p.s. Follow us at https://twitter.com/ohmyzsh.
p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.
➜  ~ 


sudo curl -L http://install.ohmyz.sh | sh
$ sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

Oh My Zsh 사용


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

프롬프트 변경하기

⇒  vi ~/.zshrc


⇒ vi  ~/.oh-my-zsh/themes/pygmalion_sixx.zsh-theme 

에서  형태로 변경  


onesixx 심홍색 %{$fg[magenta]%}%n%{$reset_color%}
            @ 청록색 %{$fg[cyan]%}@%{$reset_color%}
sixxEOS 노란색 %{$fg[yellow]%}%m%{$reset_color%}
               : 빨간색 %{$fg[red]%}:%{$reset_color%}


External Themes

~/.oh-my-zsh/custom 디렉토리 아래 themes폴더를 만들어준다. (참고로, 설치된 theme들은 ~/.oh-my-zsh/theme에)

cd ~/.oh-my-zsh/custom
mkdir themes
vi ~/.zshrc

10번째 줄



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 –     이전 히스토리 .

paste 에러

sudo subl sixx.txt~


~/.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

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