-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.bash_prompt
68 lines (59 loc) · 1.55 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Everyone needs a little color in their lives
RED='\[\033[31m\]'
GREEN='\[\033[32m\]'
YELLOW='\[\033[33m\]'
BLUE='\[\033[34m\]'
PURPLE='\[\033[35m\]'
CYAN='\[\033[36m\]'
WHITE='\[\033[37m\]'
GRAY="\[\033[1;30m\]"
NIL='\[\033[00m\]'
# Hostname styles
FULL='\H'
SHORT='\h'
# System => color/hostname map:
# UC: username color
# LC: location/cwd color
# HD: hostname display (\h vs \H)
# PC: Prompt color
# Defaults:
UC=$GREEN
LC=$CYAN
HD=$FULL
PC=$WHITE
# Prompt function because PROMPT_COMMAND is awesome
function set_prompt() {
# show the host only and be done with it.
host="${UC}${HD}${NIL}"
# Special vim-tab-like shortpath (~/folder/directory/foo => ~/f/d/foo)
_pwd=`pwd | sed "s#$HOME#~#"`
if [[ $_pwd == "~" ]]; then
_dirname=$_pwd
else
_dirname=`dirname "$_pwd" `
if [[ $_dirname == "/" ]]; then
_dirname=""
fi
_dirname="$_dirname/`basename "$_pwd"`"
fi
path="${LC}${_dirname}${NIL}"
myuser="${UC}\u@${NIL}"
myuser=""
_branch=$(git symbolic-ref HEAD 2>/dev/null)
_branch=${_branch#refs/heads/} # apparently faster than sed
branch="" # need this to clear it when we leave a repo
if [[ -n $_branch ]]; then
branch=" ${NIL}[${YELLOW}${_branch}${NIL}]"
fi
# Dollar/pound sign
end="${PC}\$${NIL} "
# Virtual Env
if [[ $VIRTUAL_ENV != "" ]]
then
venv=" ${NIL}(${GREEN}${VIRTUAL_ENV##*/}${NIL})"
else
venv=''
fi
export PS1="» ${myuser}${path}${venv}${branch}\n${end}"
}
export PROMPT_COMMAND=set_prompt