LoginSignup
3
2

More than 5 years have passed since last update.

ターミナルに git のブランチ名を表示させたり、色を変えたり。

Last updated at Posted at 2012-03-16
.bashrc
# .git-completion.bash は git のブランチ名の補完などを行なってくれる。
# ファイルは /usr/share/doc/git-VERSION/cntrib/completion/ あるいは、ソースをダウンロードしてきて、 cntrib/completion/ にあるはず。
# 以下では、現在のブランチ名が表示されるようにしている。ついでに、色を変えたり、時間を表示させたりもしている。
if [ -f ~/.git-completion.bash ]; then
    source ~/.git-completion.bash
    if [ -r "$HOME/.git-completion.bash" ]; then
        PS1='\[\033[01;32m\]\u@\h\[\033[01;33m\] \w$(__git_ps1 " (%s)") \n\[\033[00m\]$(date "+%Y/%m/%d %T") \$ ' 
    else  
        PS1="\[\033[01;32m\]\u@\h\[\033[01;33m\] \w \n\[\033[00m\]\$ "                                                                                  
    fi  
fi
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2