-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_extended
executable file
·318 lines (293 loc) · 9.59 KB
/
.bash_extended
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#!/bin/bash
#------------------------------------------////
# Lapbox ~/.bashrc file
# Last Modified 20 January 2009
# Running on Debian GNU/Linux - Lenny
#------------------------------------------////
#------------------------------------------////
# Colors:
#------------------------------------------////
black='\\\\e[0;30m'
blue='\\\\e[0;34m'
green='\\\\e[0;32m'
cyan='\\\\e[0;36m'
red='\\\\e[0;31m'
purple='\\\\e[0;35m'
brown='\\\\e[0;33m'
lightgray='\\\\e[0;37m'
darkgray='\\\\e[1;30m'
lightblue='\\\\e[1;34m'
lightgreen='\\\\e[1;32m'
lightcyan='\\\\e[1;36m'
lightred='\\\\e[1;31m'
lightpurple='\\\\e[1;35m'
yellow='\\\\e[1;33m'
white='\\\\e[1;37m'
nc='\\\\e[0m'
#------------------------------------------////
# Finding platform
#------------------------------------------////
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Darwin' ]]; then
platform='osx'
rvm reload
fi
#------------------------------------------////
# Proxy:
#------------------------------------------////
#http_proxy=http://127.0.0.1:8118/
#HTTP_PROXY=$http_proxy
#export http_proxy HTTP_PROXY
#------------------------------------------////
# Aliases:
#------------------------------------------////
## make ls list by size
##alias ls='du -s */* | sort -n'
#alias findbig='find . -type f -exec ls -s {} \; | sort -n -r | head -5'
#alias tunes='rhythmbox'
#alias ports='netstat -nape --inet'
#alias opennet='lsof -i'
#alias dsite='opera -newpage [url]http://www.debiantutorials.org[/url] &'
#alias dtadmin='opera -newpage [url]http://www.XXXXXXXXXXXX[/url] &'
#alias forum=' opera -newpage [url]http://www.debiantutorials.org/talkitup/index.php[/url] &'
#alias stats=' opera -newpage [url]http://www.XXXXXXXXXXXX[/url]'
#alias steves='ssh -p XXXX hbserv1'
#alias 150='ssh -l XXXXXX -p XXXX hbserv1'
#alias madcarters='ssh -p XXXX hbserv1 -l XXXXXX'
#alias pungent-judy='ssh -p XXXX hbserv1 -l XXXXXX'
#alias linux-impressions='ssh -p XXXX hbserv1 -l XXXXXX'
#alias debianathome='ssh -p XXXX hbserv1 -l XXXXXX'
#alias geek-feed='ssh -p XXXX hbserv1 -l XXXXXX'
#alias mcorgadmin='ssh -p XXXX hbserv1 -l XXXXXX'
alias sshinit='eval `ssh-agent` && ssh-add ~/.ssh/gerrit_rsa'
alias ping='ping -c 4'
alias ns='netstat -alnp --protocol=inet'
#alias search='aptitude search'
#alias show='aptitude show'
alias ls='ls -aF -l --color'
alias la='ls -Al --color'
alias lx='ls -lXB --color'
if [[ $platform == 'osx' ]]; then
alias ls='ls -aF -l'
alias la='ls -Al'
alias lx='ls -lXB'
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
fi
alias lk='ls -lSr'
alias lc='ls -lcr'
alias lu='ls -lur'
alias lr='ls -lR'
alias lt='ls -ltr'
alias lm='ls -al |more'
alias sn='supernova'
alias inl='inova-login'
alias vim="nvim"
alias vi="nvim"
alias oldvim="vim"
redminedir () {
title=`rore issues $1 | awk -F: '/subject/{gsub("-", "_", $2); print $2}' | python -c "print raw_input().strip().title().replace(' ', '')"`
echo "$1_$title"
}
prep() {
if [ $# -eq 0 ]; then
echo "Provide redmine ticket number"
else
dir_name=`redminedir $1`
if [ -d "$dir_name" ]; then
echo "Directory already exists"
else
mkdir $dir_name
virtualenv $dir_name/.venv --no-site-packages --distribute --prompt="($1)"
rore issues $1 --verbose > $dir_name/REDMINE
fi
fi
}
alias overseer='raxssh 10.13.1.200'
alias snailwork='source ~/bin/snail/.venv/bin/activate'
alias supernovawork='source ~/bin/supernova/.venv/bin/activate'
alias workhere='source ./.venv/bin/activate'
alias startwork='virtualenv .venv --no-site-packages --distribute --prompt="(${PWD##*/})"'
#alias rm='rm -i'
#------------------------------------------////
# Functions and Scripts:
#------------------------------------------////
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
localnet ()
{
/sbin/ifconfig | awk /'inet addr/ {print $2}'
echo ""
/sbin/ifconfig | awk /'Bcast/ {print $3}'
echo ""
}
myip ()
{
lynx -dump -hiddenlinks=ignore -nolist [url]http://checkip.dyndns.org:8245/[/url] | grep "Current IP Address" | cut -d":" -f2 | cut
-d" " -f2
}
upinfo ()
{
echo -ne "${green}$HOSTNAME ${red}uptime is ${cyan} \t ";uptime | awk /'up/ {print $3,$4,$5,$6,$7,$8,$9,$10}'
}
#cd()
#{
# if [ -n "$1" ]; then
# builtin cd "$@" && ls
# else
# builtin cd ~ && ls
# fi
#}
weather ()
{
declare -a WEATHERARRAY
WEATHERARRAY=( `lynx -dump
"[url]http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla_en-US_official&q=weather+${1}&btnG=Search[/url]" |
grep -A 5 -m 1 "Weather for" | sed 's;\[26\]Add to iGoogle\[27\]IMG;;g'`)
echo ${WEATHERARRAY[@]}
}
encrypt ()
{
gpg -ac --no-options "$1"
}
decrypt ()
{
gpg --no-options "$1"
}
extract()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.tar.Z) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.jar) unzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*) echo "'$1' cannot be extracted." ;;
esac
else
echo "'$1' is not a file."
fi
}
#------------------------------------------////
# Some original .bashrc contents:
#------------------------------------------////
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# 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)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
#------------------------------------------////
# Prompt:
#------------------------------------------////
PS1='\[\033[01;34m\]\w\[\033[00;34m\]\[\033[01;32m\]:\[\033[00m\ $(parse_git_branch)]'
PS1='\[\033[01;32m\]\u\[\033[01;34m\]@\[\033[01;31m\]\h\[\033[00;34m\]{\[\033[01;34m\]\w\[\033[00;34m\]}\[\033[01;32m\]:\[\033[00m\ $(parse_git_branch)]'
PS1='\[\033[01;31m\]\h\[\033[00;34m\]{\[\033[01;34m\]\w\[\033[00;34m\]}\[\033[01;32m\]:\[\033[00m\ $(parse_git_branch)]'
export MYPS='$(echo -n "${PWD/#$HOME/~}" | awk -F "/" '"'"'{if (length($0) > 14) { if (NF>4) print $1 "/" $2 "/.../" $(NF-1) "/" $NF; else if (NF>3) print $1 "/" $2 "/.../" $NF; else print $1 "/.../" $NF; } else print $0;}'"'"')'
PS1='$(eval "echo ${MYPS}")$ '
PS1='\[\033[01;31m\]\h\[\033[00;34m\]{\[\033[01;34m\]$(eval "echo ${MYPS}")\[\033[00;34m\]}\[\033[01;32m\]:\[\033[00m\ $(parse_git_branch)]'
#------------------------------------------////
# System Information:
#------------------------------------------////
clear
echo "Welcome to: $HOSTNAME"
dofiglet=true
command -v figlet >/dev/null 2>&1 || dofiglet=false
#if [ $dofiglet ]; then
# echo -e "${LIGHTGRAY}";figlet $HOSTNAME;
#fi
echo "User config loaded"
#echo -ne "${red}Today is:\t\t${cyan}" `date`; echo ""
#echo -e "${red}Kernel Information: \t${cyan}" `uname -smr`
#echo -ne "${cyan}";upinfo;echo ""
#echo -e "${cyan}"; cal -3
[[ -s "$HOME/.tmuxifier/init.sh" ]] && source "$HOME/.tmuxifier/init.sh"
export EDITOR="/usr/bin/vi"
# Sexy Solarized Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Customized for the Solarized color scheme by Sean O'Neil
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then TERM=gnome-256color; fi
if tput setaf 1 &> /dev/null; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
BASE03=$(tput setaf 234)
BASE02=$(tput setaf 235)
BASE01=$(tput setaf 240)
BASE00=$(tput setaf 241)
BASE0=$(tput setaf 244)
BASE1=$(tput setaf 245)
BASE2=$(tput setaf 254)
BASE3=$(tput setaf 230)
YELLOW=$(tput setaf 136)
ORANGE=$(tput setaf 166)
RED=$(tput setaf 160)
MAGENTA=$(tput setaf 125)
VIOLET=$(tput setaf 61)
BLUE=$(tput setaf 33)
CYAN=$(tput setaf 37)
GREEN=$(tput setaf 64)
else
BASE03=$(tput setaf 8)
BASE02=$(tput setaf 0)
BASE01=$(tput setaf 10)
BASE00=$(tput setaf 11)
BASE0=$(tput setaf 12)
BASE1=$(tput setaf 14)
BASE2=$(tput setaf 7)
BASE3=$(tput setaf 15)
YELLOW=$(tput setaf 3)
ORANGE=$(tput setaf 9)
RED=$(tput setaf 1)
MAGENTA=$(tput setaf 5)
VIOLET=$(tput setaf 13)
BLUE=$(tput setaf 4)
CYAN=$(tput setaf 6)
GREEN=$(tput setaf 2)
fi
BOLD=$(tput bold)
RESET=$(tput sgr0)
else
# Linux console colors. I don't have the energy
# to figure out the Solarized values
MAGENTA="\033[1;31m"
ORANGE="\033[1;33m"
GREEN="\033[1;32m"
PURPLE="\033[1;35m"
WHITE="\033[1;37m"
BOLD=""
RESET="\033[m"
fi
parse_git_dirty () {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
parse_git_branch () {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
PS1="\[${BOLD}${CYAN}\]\u \[$BASE0\]at \[$CYAN\]\h \[$BASE0\]in \[$BLUE\]\w\[$BASE0\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$YELLOW\]\$(parse_git_branch)\[$BASE0\]\n\$ \[$RESET\]"
if [ -f ~/.dir_colors ]; then
eval `dircolors ~/.dir_colors`
fi
export BASH_SILENCE_DEPRECATION_WARNING=1
~/.ssh/saveagent
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"
if test "$SSH_AUTH_SOCK" ; then
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
fi
eval "$(oh-my-posh --init --shell bash --config ~/iterm2.omp.json)"