about summary refs log tree commit diff stats
path: root/bash/prompt.bash
blob: c61266b41532e6ce3223707e5cba5e85941360e1 (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
# 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
source /usr/share/git/git-prompt.sh &&
    PS1+='\[\e[35m\]$(__git_ps1)'

# 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+='; '