-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc.versa
More file actions
199 lines (173 loc) · 5.83 KB
/
bashrc.versa
File metadata and controls
199 lines (173 loc) · 5.83 KB
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
#!/bin/sh
################################################################################
# chirag@versa-networks.com
# source scriptlet library
. $HOME/bin/lib
################################################################################
# Environment variables
export PATH=$HOME/bin:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:/usr/lib/git-core:
export HISTFILESIZE=50000
export HISTSIZE=50000
export SAVEHIST=50000
export EDITOR='vim'
export PAGER=less
export TMPDIR=/tmp
export PS1="\u@\h:\w\$ "
export SITE="IN" # "US" or "IN" for when in USA or in India
# the below colors are for linux
export LS_COLORS="no=00:fi=00:di=00;33:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:"
# colors for freebsd
#export LSCOLORS="DxFxCxDxBxEGEDABAGACAD"
export LC_ALL=C
export FORTINETDIR=$HOME/dump/archives/fortinet/forticlientsslvpn
export PRINTER="HP_HP_LaserJet_400_MFP_M425dn" # name of printer at office
#export PRINTER="HP_Deskjet_3540_series" # name of printer at home
# Embassy classic
# Shanthala Nagar, Ashok Nagar, Bangalore
# 12.970699, 77.598376
export VERSA_BLR_LON=12.970699
export VERSA_BLR_LAT=77.598376
################################################################################
# Reload History
history -r
################################################################################
# Archive mails
#$HOME/bin/archive-mails
################################################################################
# Aliases
alias wb='./waf distclean configure build'
alias adate='TZ=America/Los_Angeles date'
alias rebase='git pull --rebase'
#alias discard='git diff > /tmp/diff && awk \'/^diff/ { print $NF } \\' /tmp/diff | cut -b3- | xargs git checkout'
alias lsorig='find . -name \*.orig -o -name \#*\#'
alias waf='$PWD/waf'
alias ducks='du -cks * |sort -rn |head -11'
alias mp='mplayer -quiet -novideo -idx'
################################################################################
# TODO
[ -f $HOME/.todo ] && cat -n $HOME/.todo
################################################################################
# functions
# restart xbattbar; required when we switch from laptop screen to external monitor
restart_xbattbar() {
pkill xbattbar
xbattbar -c >/dev/null 2>&1 & disown
}
# connect to Versa Fortinet VPN
connect_to_versa() {
grep -i username $HOME/.forticlientsslvpn
if [ "$SITE" = "IN" ]; then
#VPNSERVER=115.114.125.146
VPNSERVER=182.75.39.206
VPNPORT=10443
else
#VPNSERVER=108.60.97.78
VPNSERVER=us.versa-networks.com
VPNPORT=10443
fi
cd $FORTINETDIR
verbose_exec ./forticlientsslvpn_cli --server $VPNSERVER:$VPNPORT --vpnuser $USER
}
# start VNCviewer to connect to the Versa Lab desktop
connect_to_vnc() {
VNCSRV=10.192.24.191
PASS=$HOME/.vnc/passwd
#VNCFLAGS="-truecolor -depth 16 -passwd $PASS"
VNCFLAGS="-depth 16 -compresslevel 9 -passwd $PASS"
echo "You may want to switch to new window now ... (waiting upto 5 seconds)"
sleep 5
vncviewer $VNCFLAGS $VNCSRV
}
# print PDF file
print_pdf() {
## lp -o media=Letter filename
## lpoptions -d HP_HP_LaserJet_400_MFP_M425dn -l
## PageSize/Media Size: Letter Legal Executive FanFoldGermanLegal *A4 A5 A6 B5 195x270mm 184x260mm 197x273mm Postcard DoublePostcardRotated Env10 EnvMonarch EnvISOB5 EnvC5 EnvDL Custom.WIDTHxHEIGHT
## InputSlot/Paper Source: *Auto Tray1 Tray2 Tray3 Tray1_Man
## Duplex/Two-Sided: *None DuplexNoTumble DuplexTumble
## HPOption_Tray3/Tray 3: *False True
## MediaType/Media Type: *Unspecified Plain HPEcoSMARTLite Light6074 MidWeight96110 Heavy111130 ExtraHeavy131175 MonochromeLaserTransparency Labels Letterhead Envelope Preprinted Prepunched Colored Bond Recycled Rough
## HPEconoMode/EconoMode: True *False
lp -d $PRINTER \
-o PageSize=A4 \
-o Duplex=DuplexTumble \
-o EconoMode=True \
$1
}
# setup ssh sessions in master mode so that, we can connect faster later
setup_ssh_sessions_loop() {
ssh-add -l >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Add SSH keys first"
return
fi
if ! grep -q 10.48.0.99 /etc/resolv.conf; then
sudo cp $HOME/dump/archives/netconfig/blr-work/resolv.conf /etc/resolv.conf
fi
#find $HOME/.ssh -type s -name master-\* -exec rm -f {} \;
while :
do
if [ ! -e $HOME/.active-vms ]; then
echo "$HOME/.active-vms not found"
return
fi
for vm in `grep -v ^# $HOME/.active-vms`
do
echo $vm | grep -q '@' >/dev/null 2>&1
if [ $? -eq 0 ]; then
sock=master-$vm:22
else
sock=master-${LOGNAME}@${vm}:22
fi
#echo "Checking for $sock"
if [ -e $HOME/.ssh/$sock ]; then
#echo "$vm is already setup"
continue
fi
echo -n "$vm"
ssh -fMN $vm
echo "."
done
sleep 10
done
}
# tickle offlineimap
tickle_offlineimap() {
# pid=`pgrep offlineimap`
# if [ -z "$pid" ]; then
# echo "offlineimap not running"
# else
# kill -s SIGUSR1 $pid
# echo "[$pid]"
# fi
pkill --signal SIGUSR1 offlineimap
}
# authsock
authsock() {
if [ $# -gt 0 ]; then
screen -r -S $1 -X stuff "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
else
screen -r -X stuff "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
fi
}
# kill all ssh tunnels
kill_ssh_tunnels() {
pids=$(ps ax | grep "[f]MN" | awk '{print $1}')
if [ -n "$pids" ]; then
kill $pids
fi
find $HOME/.ssh -type s -name "master-*" -exec rm -f {} \;
}
nuke_hist() {
export HISTFILE=""
}
# my procs
myprocs() {
pgrep -a "firefox|emacs|offlineimap|redshift|xbattbar|ssh-agent|dwm|xwrits"
}
# show whitespace changes
show_ws() {
git show | grep -E "^diff|^@@|^[-\+].+[[:space:]]+$"
}