-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.bashrc
59 lines (45 loc) · 1.68 KB
/
.bashrc
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
#
# .bashrc - interactive shell configuration
#
# Double-check that we are in an interactive session.
[[ $- = *i* ]] || return
# Handle resizes gracefully.
shopt -s checkwinsize
# Terminal.app sucks.
[[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && return
# Force `ls` and `grep` to be colorful under screen/tmux.
[[ "$TERM" == "screen-256color" ]] && {
alias ls="ls --color=always"
alias grep="grep --color=always"
}
# Use vcprompt.
vcprompt_ps1() {
type -p vcprompt > /dev/null && {
[[ `vcprompt -f %n` == 'svn' ]] && vcprompt -f ' at %r %m' || vcprompt -f ' on %b %m%u'
} || {
echo ''
}
# Also sneak in a bit to flush the last command to bash_history.
history -a > /dev/null
}
# a functional but sane prompt
bash_prompt() {
local NONE="\[\e[0m\]" # unsets color to term's fg color
# regular colors
local K="\[\e[0;30m\]" R="\[\e[0;31m\]" G="\[\e[0;32m\]" Y="\[\e[0;33m\]" \
B="\[\e[0;34m\]" M="\[\e[0;35m\]" C="\[\e[0;36m\]" W="\[\e[0;37m\]"
# emphasized (bolded) colors
local EMK="\[\e[1;30m\]" EMR="\[\e[1;31m\]" EMG="\[\e[1;32m\]" EMY="\[\e[1;33m\]" \
EMB="\[\e[1;34m\]" EMM="\[\e[1;35m\]" EMC="\[\e[1;36m\]" EMW="\[\e[1;37m\]"
# username/host color for root/other
(( UID != 0 )) && local UC=$W || local UC=$R
RET_VALUE='$((( RET )) && printf ":\[\e[1;31m\]$RET\[\e[0m\]")'
VC_INFO='$(vcprompt_ps1)'
# space goes inside the printf so its not there when there's no git branch
PS1=" ${EMK}┌┤${UC}\u${EMK}@${UC}\h${RET_VALUE} ${EMG}[\D{%b %d %H:%M:%S}] ${EMB}\w${EMM}${VC_INFO}${EMW}\n ${EMK}└╼${NONE} "
PS4='+$BASH_SOURCE:$LINENO:$FUNCNAME: '
}
# show return val of last command
PROMPT_COMMAND='RET=$?'
bash_prompt
unset bash_prompt