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