diff options
Diffstat (limited to 'bash/prompt.bash')
-rw-r--r-- | bash/prompt.bash | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/bash/prompt.bash b/bash/prompt.bash new file mode 100644 index 0000000..c61266b --- /dev/null +++ b/bash/prompt.bash | |||
@@ -0,0 +1,25 @@ | |||
1 | # bash prompt | ||
2 | |||
3 | PS1= | ||
4 | |||
5 | # user, host, and cwd | ||
6 | PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') | ||
7 | PS1+='\[\e[36m\]\u@\h \w' | ||
8 | |||
9 | # git bit | ||
10 | source /usr/share/git/git-prompt.sh && | ||
11 | PS1+='\[\e[35m\]$(__git_ps1)' | ||
12 | |||
13 | # newline | ||
14 | PS1+='\[\e[0m\]\n' | ||
15 | |||
16 | # exit code (only if error) | ||
17 | __prompt_exit_code() { | ||
18 | local ec=$? | ||
19 | (( $ec > 0 )) && | ||
20 | printf "$ec" | ||
21 | } | ||
22 | PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' | ||
23 | |||
24 | # delimiter | ||
25 | PS1+='; ' | ||