Skip to content

Latest commit

Β 

History

History
100 lines (89 loc) Β· 5.25 KB

File metadata and controls

100 lines (89 loc) Β· 5.25 KB

Zsh

Zshμ—λŠ” Git용 νƒ­ μžλ™μ™„μ„± μŠ€ν¬λ¦½νŠΈκ°€ λ“€μ–΄ μžˆλ‹€. .zshrc νŒŒμΌμ—μ„œ λ‹¨μˆœνžˆ autoload -Uz compinit && compinit λͺ…령을 μ‹€ν–‰ν•˜λ©΄ λœλ‹€. Zsh은 Bash보닀 더 κ°•λ ₯ν•˜λ‹€.

$ git che<tab>
check-attr        -- display gitattributes information
check-ref-format  -- ensure that a reference name is well formed
checkout          -- checkout branch or paths to working tree
checkout-index    -- copy files from index to working directory
cherry            -- find commits not merged upstream
cherry-pick       -- apply changes introduced by some existing commits

Zsh은 선택지가 μ—¬λŸ¬ 개일 λ•Œ λ‹¨μˆœνžˆ μ΄λ¦„λ§Œ 보여주지 μ•ŠλŠ”λ‹€. κ°„λ‹¨ν•œ μ„€λͺ…도 ν•¨κ»˜ 보여주고 νƒ­ ν‚€λ‘œ κ³ λ₯Ό 수 μžˆλ‹€. Git λͺ…λ Ήμ–΄λ§Œμ΄ μ•„λ‹ˆλΌ μ•„κ·œλ¨ΌνŠΈλ„ μžλ™μ™„μ„±ν•΄μ€€λ‹€. κ²Œλ‹€κ°€ μ €μž₯μ†Œμ˜ 리λͺ¨νŠΈλ‚˜ Refs 이름과 파일 이름 같은 것도 μžλ™μ™„μ„±ν•œλ‹€. Zsh은 μ•„λŠ” λͺ¨λ“  것을 μ œμ‹œν•œλ‹€.

Zshμ—λŠ” vcs_info λΌλŠ” ν”„λ ˆμž„μ›Œν¬κ°€ 포함돼 μžˆλ‹€. μ—¬κΈ°μ—λŠ” ν˜„μž¬ μ‚¬μš©ν•˜λŠ” VCS정보가 λ“€μ–΄μžˆλ‹€. ~/.zshrc νŒŒμΌμ— μ•„λž˜ 라인을 μΆ”κ°€ν•˜λ©΄ 였λ₯Έμͺ½ ν”„λ‘¬ν”„νŠΈμ— 브랜치 이름이 ν‘œμ‹œλœλ‹€.

autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
RPROMPT=\$vcs_info_msg_0_
# PROMPT=\$vcs_info_msg_0_'%# '
zstyle ':vcs_info:git:*' formats '%b'

μ‰˜μ—μ„œ Git μ €μž₯μ†Œ λ””λ ‰ν† λ¦¬λ‘œ μ΄λ™ν•˜λ©΄ 터미널 였λ₯Έμͺ½μ— ν˜„ 브랜치 이름을 μ•„λž˜μ™€ 같이 보여쀀닀. (λ¬Όλ‘  주석 μ²˜λ¦¬ν•œ κ²ƒλ§Œ 돌리면 μ™Όμͺ½ ν”„λ‘¬ν”„νŠΈμ—μ„œλ„ 잘 λœλ‹€.)

`zsh` ν”„λ‘¬ν”„νŠΈ μ„€μ •.
Figure 1. zsh ν”„λ‘¬ν”„νŠΈ μ„€μ •.

vcs_info에 λŒ€ν•œ μžμ„Έν•œ μ •λ³΄λŠ” zshcontrib(1) 메뉴얼 νŽ˜μ΄μ§€λ₯Ό λ³΄κ±°λ‚˜ http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Version-Control-Informationμ—μ„œ ν™•μΈν•œλ‹€.

vcs_info말고 Git에 λ“€μ–΄ μžˆλŠ” git-prompt.sh λ₯Ό 직접 μˆ˜μ •ν•΄μ„œ μ‚¬μš©ν•΄λ„ λœλ‹€. μžμ„Έν•œ λ‚΄μš©μ€ https://github.com/git/git/blob/master/contrib/completion/git-prompt.shμ—μ„œ ν™•μΈν•œλ‹€. git-prompt.sh λŠ” Bash와 Zsh λͺ¨λ‘ ν˜Έν™˜λœλ‹€.

Zsh의 강령함을 μ΄λŒμ–΄ λ‚΄λŠ” ν”„λ ˆμž„μ›Œν¬κ°€ μžˆλ‹€. "oh-my-zsh"이 λŒ€ν‘œμ μΈλ° https://github.com/robbyrussell/oh-my-zshμ—μ„œ 찾을 수 μžˆλ‹€. Git νƒ­ μžλ™μ™„μ„±λ„ "oh-my-zsh" ν”ŒλŸ¬κ·ΈμΈμ„ μ‚¬μš©ν•˜λ©΄ 되고 브랜치 μ΄μƒμ˜ 정보λ₯Ό λ³΄μ—¬μ£ΌλŠ” λ‹€μ–‘ν•œ ν”„λ‘¬ν”„νŠΈ ν…Œλ§ˆλ„ μ œκ³΅ν•œλ‹€. oh-my-zsh ν…Œλ§ˆ.은 ν”„λ‘¬ν”„νŠΈ ν…Œλ§ˆλ₯Ό μ μš©ν•œ λͺ¨μŠ΅μ΄λ‹€.

oh-my-zsh ν…Œλ§ˆ.
Figure 2. oh-my-zsh ν…Œλ§ˆ.