git을 이용해 작업을 하다보며 현재 브랜치를 종종 깜빡하는 경우가 있습니다. 그럴때마다 git branch 명령어를 입력하기는 좀 귀찮죠. 이것은 쉘에 branch를 출력하면 아주 편하게 해결할 수 있습니다.
아래와 같이 진행합니다.
1. vi ~/.bashrc
2. 가장 아래에 아래 입력합니다.
# Show git branch name
force_color_prompt=yes
color_prompt=yes
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
unset color_prompt force_color_prompt
3. source ~/.bashrc
그럼 아래와 같은 사진을 확인할 수 있습니다.
참고 : https://blog.seoft.co.kr/24
ubuntu 터미널 현 디렉토리 우측에 git branch 출력
[문제정의] 다음과같이 ubuntu 터미널 현 디렉토리 우측에 git current branch 출력하기 위함 [해결방안] 0. 작업 환경 ubuntu16.04기준 (18.04도 확인완료) mobaXterm client로 테스트 1. ~/.bashrc 파일의 가장..
blog.seoft.co.kr