最終更新 1 month ago

修正履歴 38d0b6e86b10695daf475720a869b77641f8e495

prompt.sh Raw
1txtwht="\[\e[00m\]" # White
2txtred="\[\e[0;31m\]" # Red
3txtgrn="\[\e[0;32m\]" # Green
4txtpur="\[\e[0;35m\]" # Purple
5txtblu="\[\e[0;34m\]" # Blue
6bldgrn="\[\e[1;32m\]" # Green
7bldcyn="\[\e[1;36m\]" # Cyan
8
9function parse_git_this_branch {
10 git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
11}
12
13function parse_git_deleted {
14 [[ $(git status 2> /dev/null | grep deleted:) != "" ]] && echo "-"
15}
16function parse_git_added {
17 [[ $(git status 2> /dev/null | grep "Untracked files:") != "" ]] && echo "+"
18}
19function parse_git_modified {
20 [[ $(git status 2> /dev/null | grep modified:) != "" ]] && echo "*"
21}
22function parse_git_dirty {
23 echo "$(parse_git_added)$(parse_git_modified)$(parse_git_deleted)"
24}
25function parse_git_branch {
26 git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
27}
28function parse_ps1 {
29 echo "${bldcyn}[\W]${txtwht}\$(parse_git_branch)\n$> "
30}
31
32if [ "$color_prompt" = yes ]; then
33 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
34else
35 PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
36fi
37unset color_prompt force_color_prompt
38
39export PS1=$(parse_ps1)
40ps1_set --prompt ∴
41