bash prompt에 git branch name을 color로 표시하는 방법입니다.
.bashrc에 적용하니까 보기가 좋습니다.
참고로 저는 ubuntu 16.04에서 테스트 했습니다.
수정된 .basrc 파일은 첨부 파일을 참고하세요^^
1. .bashrc 파일의 아래 부분을 주석 처리하고 내용 추가
#if [ "$color_prompt" = yes ]; then # PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' #else # PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' #fi parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ ' fi |
2. PS1 부분을 주석처리 하고 내용 추가
# If this is an xterm set the title to user@host:dir case "$TERM" in xterm*|rxvt*) #PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' ;; *) ;; esac |
# 수정 전
# 수정 후(git branch name에 color로 표시)
※ 참고 사이트 ※
★https://askubuntu.com/questions/730754/how-do-i-show-the-git-branch-with-colours-in-bash-prompt https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt |
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
저는 IT 기술에 대해 관심이 많고, 기술적인 토론하는 것을 매우 좋아합니다^^ github following 해주시면 정말로 감사하겠습니다^^ github: https://github.com/jhhwang4195 어떠한 댓글이든 환영합니다^^ 댓글 좀 달아주세요^^ (구걸 모드) |
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
이 글이 도움이 되셨다면 아래에 있는 "♡공감" 버튼을 클릭해주세요
'버전 관리 > git' 카테고리의 다른 글
[TIP] reset 명령을 이용한 undo 하기 (0) | 2017.12.19 |
---|---|
[TIP] git branch graph (git log extension) (0) | 2017.12.19 |
[TIP] github에 https/ssh push (skip password) (1) | 2017.12.19 |
[TIP] git merge 정리 (vimdiff 사용) (0) | 2017.12.18 |
[TIP] 리눅스 서버에 git 서버 구축하기 (0) | 2017.12.18 |