-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_prompt
42 lines (41 loc) · 1.12 KB
/
.bash_prompt
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
38
39
40
41
42
#!/bin/bash
set_prompt()
{
local last_cmd=$?
local txtreset='$(tput sgr0)'
local txtbold='$(tput bold)'
local txtblack='$(tput setaf 0)'
local txtred='$(tput setaf 1)'
local txtgreen='$(tput setaf 2)'
local txtyellow='$(tput setaf 3)'
local txtblue='$(tput setaf 4)'
local txtpurple='$(tput setaf 5)'
local txtcyan='$(tput setaf 6)'
local txtwhite='$(tput setaf 7)'
# unicode "✗"
local fancyx='\342\234\227'
# unicode "✓"
local checkmark='\342\234\223'
PS1=""
# User color: red for root, yellow for others
if [[ $EUID == 0 ]]; then
PS1+="\[$txtred\]"
else
PS1+="\[$txtyellow\]"
fi
# user@host
PS1+="\u\[$txtwhite\]@\h "
# current path
PS1+="\[$txtgreen\]\w"
# # a red "✗" or a green "✓" and the error number
# if [[ $last_cmd == 0 ]]; then
# PS1+="\[$txtgreen\]$checkmark \[$txtwhite\](0)"
# else
# PS1+="\[$txtred\]$fancyx \[$txtwhite\]($last_cmd)"
# fi
# green git branch
PS1+="\[$txtgreen\]$(__git_ps1 ' (%s)')\[$txtwhite\]"
# good old prompt, $ for user, # for root
PS1+=" \\$ "
}
PROMPT_COMMAND='set_prompt'