-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
executable file
·134 lines (106 loc) · 2.57 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
#!/bin/bash
if [ -f /etc/bash_completion ]; then
source /etc/bash_completion
fi
export PATH=/usr/local/bin:/usr/local/sbin:$PATH:~/pear:~/bin
export EDITOR=vim
export VISUAL=vim
export HISTCONTROL=ignoreboth
export HISTTIMEFORMAT="%F %T "
build_prompt () {
local reset_color="\[\e[0;0m\]"
local user_color="\[\e[\$(user_prompt_color)m\]"
local user_prompt="${user_color}\$(user_prompt_text)${reset_color}"
local at_color="\[\e[0;90m\]"
local at_prompt="${at_color}@${reset_color}"
local host_color="\[\e[0;36m\]"
local host_prompt="${host_color}"$(host_prompt_text)"${reset_color}"
local git_color="\[\e[0;35m\]"
local git_prompt="${git_color}\$(git_prompt_text)${reset_color}"
local aws_color="\[\e[\$(aws_prompt_color)m\]"
local aws_prompt="${aws_color}\$(aws_prompt_text)${reset_color}"
local vim_color="\[\e[4;33m\]"
local vim_prompt="${vim_color}\$(vim_prompt_text)${reset_color}"
local prompt_color="\[\e[\$(prompt_char_color)m\]"
local prompt_prompt="${prompt_color}\$(prompt_char_text)${reset_color}"
echo "${user_prompt}${at_prompt}${host_prompt}${git_prompt}${aws_prompt}\$(vim_prompt_padding)${vim_prompt}${prompt_prompt} "
}
prompt_char_color () {
if [ "$USER" == "root" ]; then
echo "1;31"
else
echo "0;90"
fi
}
prompt_char_text () {
if [ "$USER" == "root" ]; then
echo "#"
else
echo ">"
fi
}
host_prompt_text () {
echo "\h"
}
user_prompt_color () {
if [ "$USER" == "root" ]; then
printf "1;31"
else
printf "0;90"
fi
}
user_prompt_text () {
echo "$USER"
}
vim_prompt_padding () {
if [ ! -z "$VIM" ]; then
printf " "
fi
}
dpwd_prompt_text () {
if [ ! -z `declare -f -F dpwd` ]; then
local dpwd=`dpwd`
if [ ! -z "$dpwd" ]; then
echo " ${dpwd}"
fi
fi
}
vim_prompt_text () {
if [ ! -z "$VIM" ]; then
printf "vim"
fi
}
git_prompt_text () {
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
local git_branch=$(git rev-parse --abbrev-ref HEAD)
echo " (${git_branch})"
}
aws_prompt_color () {
if [[ $AWS_PROFILE = *"Prod"* ]]; then
printf "1;31"
elif [[ $AWS_PROFILE = *"Staging"* ]]; then
printf "0;34"
else
printf "0;90"
fi
}
aws_prompt_text () {
if [ ! -z "$AWS_PROFILE" ]; then
echo " (AWS=${AWS_PROFILE})"
fi
}
export PS1=$(build_prompt)
alias ls="/bin/ls -F"
alias du="du -cks"
alias vi="vim"
alias reconf="cd ..; aclocal; autoheader; autoconf; automake -a; ./configure; make clean; make; cd src"
alias newpw="pwgen -n 32 1 | tr -d '\n' | pbcopy"
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac