を公開してみる
gitps1=":"
if [ -r /usr/local/etc/git/git-prompt.sh ]; then
. /usr/local/etc/git/git-prompt.sh
gitps1="__git_ps1"
fi
if [ "${TERM}" = "linux" ]; then
export PS1='\[\e[32m\]\u@\h \[\e[33m\][\w]\[\e[0m\]\$ '
else
export PS1='\[\e]0;\w\a\]\[\e[32m\]\u@\h \[\e[33m\][\w]$(${gitps1})\[\e[0m\]\$ '
fi
gitps1 の中は最初は「何もしないコマンド ":"」を入れておき、 git-prompt.sh が存在した場合のみ git の branch を表示させる関数に差し替える.
PS1 の中の説明は色を付けるコードがゴチャゴチャしているが、表示する内容にかかわっているのだけに直すと以下のコードとなる.
PS1='\u@\h [\w] \$'
- \u はユーザー名
- \h はホスト名
- \w は自分がいるPathの表示
- \\$ は自分が一般ユーザーなら \$ を root なら # を表示する
他の option を知りたければ
$ man bash
の 「PROMPTING」の章に色々と載ってるので参考にしてみてください.
色コードに関してはまた後日