-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.bash_profile
206 lines (153 loc) · 5.26 KB
/
.bash_profile
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# # # # # # # # # # # # # # # # # # # # # # # # # # # #
# _ _ __ _ _ #
# | |__ __ _ __| |_ _ __ _ _ ___ / _(_) |___ #
# _| '_ \/ _` (_-< ' \ | '_ \ '_/ _ \ _| | / -_) #
# (_)_.__/\__,_/__/_||_|__| .__/_| \___/_| |_|_\___| #
# |___|_| #
# # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Colors
[[ -r "$(dirname "$BASH_SOURCE")/.bash_profile__colors" ]] && source "$(dirname "$BASH_SOURCE")/.bash_profile__colors"
###############
### ALIASES ###
###############
alias psg='ps aux | grep'
alias ll='ls -hal'
alias grep='grep --color'
alias l='ls'
alias cl='curl -L'
alias ..='cd ..'
alias ...='cd ...'
alias sl='ls'
alias c='clear'
alias matrix='LC_ALL=C tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"'
alias lastchanges='find . -type f -print0 | xargs -0 stat -f "%m %N" | sort -rn | cut -f2- -d" "'
alias flush__memcached="echo 'flush_all' | nc localhost 11211"
alias flush__dns="dscacheutil -flushcache"
#alias reset_launchpad="defaults write com.apple.dock ResetLaunchPad -bool true && killall Dock"
###############
### UTILITY ###
###############
# bash_prifile get project path
function bash_profile__path {
echo $(dirname "$BASH_SOURCE")
}
# bash_profile move to project folder
function bash_profile__cd {
cd $(bash_profile__path)
}
# bash_profile get version
function bash_profile__version {
cat ~/bash_profile/VERSION
}
# bash_profile reload the project
function bash_profile__reload {
source $(bash_profile__path)/.bash_profile
}
# bash_profile reload your own .bash_profile or .bashrc
function bash_profile__reload_all {
[[ -r "$HOME/.bash_profile" ]] && source ~/.bash_profile
[[ -r "$HOME/.bashrc" ]] && source ~/.bashrc
}
# bash_profile update
function bash_profile__update {
message=`git -C $(bash_profile__path) checkout . && git -C $(bash_profile__path) pull -r`
if [[ $message == *"is up to date"* || $message == *"up-to-date"* ]]; then
echo;
echo -e "$COLOR_ALT_CYAN""----------------------"
echo -e "$COLOR_ALT_CYAN""BASH_PROFILE"
echo -e "$COLOR_CYAN""no update available"
echo -e "$COLOR_ALT_CYAN""----------------------"
echo -e "$COLOR_NORMAL"
else
if [[ $message != "" ]]; then
echo $message > $(bash_profile__path)/UPDATED
fi
fi
}
# Utility
[[ -r "$(bash_profile__path)/.bash_profile__utility" ]] && source "$(bash_profile__path)/.bash_profile__utility"
###########
### GIT ###
###########
# compose a useful string containing git information
function gitify {
echo ""
}
[[ $(cli__is_installed git) == true ]] && source $(bash_profile__path)/.bash_profile__git
# Bash Completions
[[ -r "$(bash_profile__path)/.bash_completion_git" ]] && source $(bash_profile__path)/.bash_completion_git
###########
### SVN ###
###########
# compose a useful string containing svn information
function svnify {
echo ""
}
[[ $(cli__is_installed svn) == true ]] && source $(bash_profile__path)/.bash_profile__svn
# Bash Completions
[[ -r "$(bash_profile__path)/.bash_completion_svn" ]] && source $(bash_profile__path)/.bash_completion_svn
###########
### SSH ###
###########
# Bash Completions
[[ -r "$(bash_profile__path)/.bash_completion_ssh" ]] && source $(bash_profile__path)/.bash_completion_ssh
###########
### PS1 ###
###########
function __bash_profile__check_updates {
if [[ -f $(bash_profile__path)/UPDATED ]]; then
bash_profile__reload
echo;
echo -e "$COLOR_ALT_GREEN""---------------------------"
echo -e "$COLOR_ALT_GREEN""BASH_PROFILE"
echo -e "$COLOR_GREEN""updated to version $(bash_profile__version)"
echo -e "$COLOR_ALT_GREEN""---------------------------"
echo;
echo -e "$COLOR_GREEN""🗣 What's New - https://goo.gl/EKaOnc"
echo -e "$COLOR_NORMAL"
rm $(bash_profile__path)/UPDATED
fi
}
function __bash_profile__set_prompt {
PS1="\n\[$COLOR_GREEN\][\w]\[$COLOR_YELLOW\] $(gitify) $(svnify) \n\[$COLOR_CYAN\][\u@\h \$] \[$COLOR_RED\]> \[$COLOR_NORMAL\]"
}
export PROMPT_COMMAND="__bash_profile__check_updates; __bash_profile__set_prompt; $PROMPT_COMMAND"
###############
### EXPORTS ###
###############
export GIT_EDITOR="vim"
export SVN_EDITOR="vim"
export EDITOR="vim"
export CLICOLOR=1
export LSCOLORS=gxfxcxdxbxegedabagacad
#####################
### SPLASH SCREEN ###
#####################
function __bash_profile__splash_screen {
echo;
echo -e " _ _ __ _ _ "
echo -e " | |__ __ _ __| |_ _ __ _ _ ___ / _(_) |___ "
echo -e " _| '_ \/ _\` (_-\< ' \ | '_ \\ '_/ _ \ _| | / -_) "
echo -e " (_)_.__/\__,_/__/_||_|__| .__/_| \___/_| |_|_\___| "
echo -e " |___|_| "
echo -e " "$(bash_profile__version)
echo;
echo;
}
###############
### GETOPTS ###
###############
OPTIND=1
while getopts "wup:" OPT; do
case $OPT in
w)
__bash_profile__splash_screen
;;
u)
(bash_profile__update > /dev/null 2>&1 &)
;;
p)
proxy__set $OPTARG
;;
esac
done