-
Notifications
You must be signed in to change notification settings - Fork 2
/
.bashrc
74 lines (64 loc) · 2.17 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Run .profile
if [[ -e $HOME/.profile ]]; then source $HOME/.profile; fi
# Don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth
# Check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
# Enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if type brew >/dev/null 2>&1; then
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
fi
# Set prompt variables
# From: http://www.jonmaddox.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
function setPromptVars {
P_GITBRANCH=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' -e 's/^/[git:/' -e 's/$/]/')
P_HGTIP=$(hg branch 2> /dev/null | sed -e 's/^/[hg:/' -e 's/$/]/')
}
# Set prompt
function setPromptText {
local RETCODE=$?
local YELLOW="\[\033[0;33m\]"
local BLUE="\[\033[0;34m\]"
local LIGHT_BLUE="\[\033[0;36m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
local NORMAL="\[\033[0m\]"
case $TERM in
xterm*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
local P_USER="\u"
local P_HOST="\h"
local P_DATE="\d"
local P_TIME="\t"
local P_PWD="\w"
local P_COUNT="\#"
local P_RETCODE=""
if [ $RETCODE -ne 0 ]; then
P_RETCODE="[$RETCODE]"
fi
setPromptVars
PS1="$LIGHT_BLUE${P_USER}$GREEN@$RED${P_HOST}$YELLOW${P_GITBRANCH}${P_HGTIP}$GREEN [${P_DATE}/${P_TIME}] [${P_PWD}] [${P_COUNT}] $RED${P_RETCODE}$NORMAL\n"
PS2='> '
PS4='+ '
}
# Set 'setPromptText' to be executed on each new prompt
# See: http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x264.html
export PROMPT_COMMAND=setPromptText