Zsh :: oh-my-zsh

Published onesixx on

http://www.zsh.org/
https://github.com/robbyrussell/oh-my-zsh/
https://github.com/robbyrussell/oh-my-zsh/wiki/themes
https://spyrosoft.com/blog/why-to-switch-from-bash-to-zsh.html
http://coding-korea.blogspot.kr/2012/09/zsh.html?m=1
http://zsh.sourceforge.net/Guide/zshguide.pdf

Zsh 설치 이유

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

현재 환경

Shell

Zsh 설정 파일 로딩 순서 

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

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

.zshenv

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.

.zshrc

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

.zlogin

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

.zprofile

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

.zlogout

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.

oh-my-zsh

http://ohmyz.sh/

Shell

Themes

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

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

https://github.com/romkatv/powerlevel10k

Shell

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

Enabling Plugins

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

vi /.zshrc

54번째줄 

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

Shell

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

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

Shell

3. Commandline fuzzy finder 플러그인 –  fzf

기본적인 기능

Shell

에러

paste 에러

https://cirw.in/blog/bracketed-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
  LBUFFER+=$_paste_content
  unset _paste_content
}

function _paste_insert() {
  _paste_content+=$KEYS
}

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

onesixx

Blog Owner

guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x