blob: df30c82097a6fe8765b193dcbfc91f5697365c14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# bash prompt
PS1=
# user, host, and cwd
PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...')
PS1+='\[\e[36m\]\u@\h \w'
# git bit
# see https://unix.stackexchange.com/questions/278206
possible_git_prompt_locations=(
/usr/share/git/git-prompt.sh # Arch, etc. (default?)
/usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ...
/usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ??
)
for file in "${possible_git_prompt_locations[@]}"; do
if [[ -f "$file" ]]; then
source "$file" &&
PS1+='\[\e[35m\]$(__git_ps1)'
break
fi
done
# newline
PS1+='\[\e[0m\]\n'
# exit code (only if error)
__prompt_exit_code() {
local ec=$?
(( $ec > 0 )) &&
printf "$ec"
}
PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]'
# delimiter
PS1+='; '
|