forked from jarv/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotfile.bashrc
144 lines (117 loc) · 2.93 KB
/
dotfile.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# .bashrc
umask 022
join_dirs()
{
for STRING in $*; do
[[ -d $STRING ]] && JOINED=$JOINED:$STRING
done
echo $JOINED | sed -e 's/^://'
}
PATHDIRS=(
/usr/local/bin
/usr/local/sbin
)
PATH=`join_dirs ${PATHDIRS[*]}`:$PATH
unset PATHDIRS
case `uname -s` in
[Ll]inux)
;;
Darwin)
;;
SunOS)
;;
esac
# Pretty ls colors
[[ -n "`ls --version 2> /dev/null`" ]] && alias ls=`which ls`" --color=tty -F"
[[ -x "`which dircolors`" ]] && eval `dircolors`
EDITOR=`which vim`
VISUAL=$EDITOR
FCEDIT=$EDITOR
PAGER=`which less`
FIGNORE=.o:~
LESS="-f-R-P?f[%f]:[STDIN].?m(file %i of %m)?x[Next\: %x]. .?lb [line %lb?L/%L]..?e(END) :?pB [%pB\%]..%t"
RI='--format ansi'
GREP_OPTIONS='--color=auto'
# Source the completion file, if it exists
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
# Add hostname completion to some new programs
complete -F _known_hosts xvncviewer nc
fi
if [ "$BASH_VERSINFO" -ge 2 ]; then
shopt -s cdspell
shopt -s checkwinsize
shopt -s cmdhist
shopt -s histappend
shopt -s checkhash
shopt -s no_empty_cmd_completion
shopt -s execfail
HISTFILESIZE=10000
HISTDIR="$HOME/.bash_histories/`uname -n`"
[[ ! -d $HISTDIR ]] && mkdir -p "$HISTDIR"
HISTFILE="$HISTDIR/`date +%Y_%m`"
# Suppress duplicates, bare "ls" and bg,fg and exit
HISTIGNORE="&:ls:[bf]g:exit"
fi
# Colors and PS1
_NORM="\033[0m"
_BLK="\033[0;30m"
_RED="\033[0;31m"
_GRN="\033[0;32m"
_YEL="\033[0;33m"
_BLU="\033[0;34m"
_MAG="\033[0;35m"
_CYN="\033[0;36m"
_WHT="\033[0;37m"
_BBLK="\033[1;30m"
_BRED="\033[1;31m"
_BGRN="\033[1;32m"
_BYEL="\033[1;33m"
_BBLU="\033[1;34m"
_BMAG="\033[1;35m"
_BCYN="\033[1;36m"
_BWHT="\033[1;37m"
case `uname -n` in
*)
PAREN_COLOR="\[${_GRN}\]"
MC="\[${_BGRN}\]"
DC="\[${_BLU}\]"
;;
esac
# OP is Open Paren
OP="${PAREN_COLOR}("
# CP is Close Paren
CP="${PAREN_COLOR})"
# Root Overrides
if [ `id | cut -b5` = 0 ]; then
MC="\[${_BRED}\]"
fi
PS1HOST="${OP}${MC}\u${DC}@${MC}\h${CP}"
PS1DATE="${OP}${DC}\d${CP}"
PS1TIME="${OP}${DC}\t${CP}"
PS1TTY="${OP}${DC}$(tty)${CP}"
PS1DIR="${OP}${DC}\w${CP}"
PS1RETVAL="${OP}${DC}\${?}${CP}"
PS1END="\[$_NORM\]\r\n\[$_WHT\]\\$ "
case $TERM in
[Ex]term*) TITLE_WINDOW="\[\033]0;\h :: \w\007\]" ;;
*) TITLE_WINDOW='' ;;
esac
for script in $HOME/.bashrc.d/*; do
source $script
done
# Some things need to be computed.
prompt_cmd() {
# Compute RETVAL
FAIL=$?
if [[ $FAIL -eq 0 ]]; then
PS1RETVAL="${OP}${DC}0${CP}"
else
PS1RETVAL="${OP}\[${_BRED}\]${FAIL}${CP}"
fi
history -a # Save last user cmd to bash_history
PS1="${TITLE_WINDOW}${PS1HOST}${PS1RETVAL}$(__git_ps1)${PS1DIR}${PS1END}"
}
PROMPT_COMMAND=prompt_cmd
PS1="${TITLE_WINDOW}${PS1HOST}${PS1RETVAL}$(__git_ps1)${PS1DIR}${PS1END}"
export PATH PS1 EDITOR VISUAL PAGER LESS FCEDIT SEPATH MANPATH TERM GREP_OPTIONS RI HISTFILESIZE HISTFILE HISTIGNORE