-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
142 lines (117 loc) · 3.11 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
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
# Keep some basic and interesting stuff
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# 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 ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# And now Customize
export CDPATH=~:~/Projects
eval "`dircolors`"
alias ls='ls --color=auto'
alias ll='ls -lAF'
alias l='ll'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ps='ps fauxwww'
alias j='jobs'
export HISTTIMEFORMAT="%d/%m/%y %T "
export HISTFILESIZE="10000"
export HISTSIZE="1000"
export HISTCONTROL="ignoredups"
export HISTIGNORE="j:jobs:cd:bg:fg*:ls:l:ll:exit:history*:top:ps:screen:tmux"
function bk() {
if [ $# -eq 1 ]
then
if [ -f $1.1 ]
then
Z=$(find ./$1.[0-9]* | awk -F"." '{ print $NF }' | sort -h | tail -n1)
for ((i=$Z;i>0;i-=1))
do
mv $1.$i $1.$((i+1))
done
fi
mv $1 $1.1
fi
}
function _GIT() {
git status -s > /dev/null 2>&1
if [ $? -eq 0 ]
then
BRANCH=$(git branch | awk '{ if ($1 == "*") { print $2 } }')
if [ $(git status -s | wc -l) -ne 0 ]
then
echo -e " \[\e[1;31m\]${BRANCH}"
else
echo -e " \[\e[1;37m\]${BRANCH}"
fi
fi
}
function __prompt_command() {
local EXIT="$?" # This needs to be first
local Red='\[\e[1;31m\]'
local URed='\[\e[4;31m\]'
local Gre='\[\e[1;32m\]'
local UGre='\[\e[4;32m\]'
local Yel='\[\e[1;33m\]'
local UYel='\[\e[4;33m\]'
local Blu='\[\e[1;34m\]'
local Pur='\[\e[1;35m\]'
PS1=""
if [ $TERM == "screen" ]
then
SCREENSTART="${Pur}["
SCREENEND="${Pur}]"
else
SCREENSTART=''
SCREENEND=''
fi
PS1+=$SCREENSTART
if [ $USER == "root" ]
then
PS1+="${UGre}\u${UYel}@${URed}\h\[\033[0m\]"
else
PS1+="${Gre}\u${Yel}@${Red}\h\[\033[0m\]"
fi
PS1+="${Blu} \w"
PS1+=$(_GIT)
if [ $EXIT != 0 ]; then
PS1+="${Red} ${EXIT}"
else
PS1+="${Gre} ${EXIT}"
fi
PS1+=$SCREENEND
PS1+="\[\e[1;30m\] \\\$ \[\033[0m\]"
}
export PROMPT_COMMAND=__prompt_command
alias stow-sys="stow -d /usr/local/stow/ -t /usr/local/"
alias stow-home="stow -d $HOME/stow/ -t $HOME/"
export GOROOT=$HOME/go
export GOPATH=$HOME/Projects/GO/gocode
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:$HOME/bin
export DEBEMAIL="[email protected]"
export DEBFULLNAME="Jeremy Clerc"
function add_role {
mkdir -v -p $1/{files,templates,tasks,handlers,vars}
}