about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--bash/prompt.bash27
1 files changed, 15 insertions, 12 deletions
diff --git a/bash/prompt.bash b/bash/prompt.bash index df30c82..02d9c98 100644 --- a/bash/prompt.bash +++ b/bash/prompt.bash
@@ -4,22 +4,25 @@ PS1=
4 4
5# user, host, and cwd 5# user, host, and cwd
6PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') 6PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...')
7PS1+='\[\e[36m\]\u@\h \w' 7PS1+='\[\e[34m\]# \u@\h \w'
8 8
9# git bit 9# git bit
10# see https://unix.stackexchange.com/questions/278206 10# see https://unix.stackexchange.com/questions/278206
11possible_git_prompt_locations=( 11possible_git_prompt_locations=(
12 /usr/share/git/git-prompt.sh # Arch, etc. (default?) 12 /usr/share/git/git-prompt.sh # Arch, etc. (default?)
13 /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ... 13 /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ...
14 /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ?? 14 /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ??
15 # I have yet to find Alpine's git prompt location.
15) 16)
16 17
17for file in "${possible_git_prompt_locations[@]}"; do 18for file in "${possible_git_prompt_locations[@]}"; do
18 if [[ -f "$file" ]]; then 19 if [[ -f "$file" ]]; then
19 source "$file" && 20 source "$file" &&
20 PS1+='\[\e[35m\]$(__git_ps1)' 21 PS1+='\[\e[35m\]$(__git_ps1)'
21 break 22 break
22 fi 23 else
24 true
25 fi
23done 26done
24 27
25# newline 28# newline
@@ -27,9 +30,9 @@ PS1+='\[\e[0m\]\n'
27 30
28# exit code (only if error) 31# exit code (only if error)
29__prompt_exit_code() { 32__prompt_exit_code() {
30 local ec=$? 33 local ec=$?
31 (( $ec > 0 )) && 34 (( $ec > 0 )) &&
32 printf "$ec" 35 printf "$ec"
33} 36}
34PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' 37PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]'
35 38