-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_bash_aliases
More file actions
154 lines (127 loc) · 4.63 KB
/
_bash_aliases
File metadata and controls
154 lines (127 loc) · 4.63 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
#!/bin/bash
# this is sourced in ~/.bashrc
# add aliases here on a whim
alias realias='$EDITOR ~/.bash_aliases; source ~/.bash_aliases'
# since this might go to a public repo. move private stuff to a different file
if [ -f ~/.bash_private ]; then
. ~/.bash_private
fi
# Do I have Random::Module installed and what version it is?
function pmver () {
echo -n "$1 is ";
perl -M$1 -E"say $1->VERSION" 2>/dev/null || echo unavailable
}
# functions to quickly set cpu governor when out of black goats for cpufreqd
function cpu-save() {
for cpu in 0 1 ; do
sudo cpufreq-set -g powersave -c $cpu
done
}
function cpu-perf() {
for cpu in 0 1 ; do
sudo cpufreq-set -g performance -c $cpu
done
}
# function to quickly delete given line in known_hosts
# TODO: write something saner using ssh-keygen -F and -R
function ssh-del() {
sed -i -e ${1}d ~/.ssh/known_hosts
}
# experimental use of vim for manpages
vman() {
if [ $# -eq 0 ]; then
/usr/bin/man
else
if man -w $* >/dev/null 2>/dev/null
then
/usr/bin/man $* | col -b | vim -c 'set ft=man nomod' -
else
echo No man page for $*
fi
fi
}
declare -A mailman_lists
mailman_lists[humor]="http://lists.lug.ro/mailman/admindb/humor"
mailman_lists[anunt]="http://lists.lug.ro/mailman/admindb/anunt"
mailman_lists[org]="http://lists.lug.ro/mailman/admindb/org"
mailman_lists[rlug]="http://lists.lug.ro/mailman/admindb/rlug"
mailman_lists[prolinux]="http://lists.lug.ro/mailman/admindb/prolinux"
mailman_lists[webteam]="http://lists.lug.ro/mailman/admindb/webteam"
function mmurl {
if [ -n "${mailman_passwords[$1]}" ]; then
echo "${mailman_lists[$1]}?admpw=${mailman_passwords[$1]}"
else
echo "${mailman_lists[$1]}"
fi
}
function mmcheck {
[ ${#mailman_lists[*]} -eq 0 ] && return 0
for list in ${!mailman_lists[*]} ; do
python ~/bin/mmfold.py $(mmurl $list)
done
}
alias rot13='perl -ple "y/A-Za-z/N-ZA-Mn-za-m/"'
alias gist='nopaste --private --service Gist --language plain'
alias rlug='nopaste --service Rlug --nick rpetre --language plain'
# Extract password from gpg storage for host $1
function getpass () {
gpg --batch --decrypt /opt/work/safebox/cvs/passwords/root.linux.passwords.asc 2>/dev/null | perl -le 'while (<STDIN>) { @F = split ; if ($F[3] eq $ARGV[0])
{ print $F[-1]; print STDERR qq(password for $ARGV[0] is in the clipboard); exit }}
print STDERR qq($ARGV[0] not found in password file)' $1 | xclip
}
alias vimhelp='vim -c "he|on"'
function ec2-setup () {
# ec2 setup, based on https://github.com/fapestniegd/smegami/blob/master/ec2-setup
# has been tested only on a scratch install, so when in doubt, backup your certs and wipe EC2_HOME
EC2_AMITOOL_HOME="$EC2_HOME/ec2-ami-tools"
EC2_APITOOL_HOME="$EC2_HOME/ec2-api-tools"
AMI_BIN=${EC2_AMITOOL_HOME}/bin/
API_BIN=${EC2_APITOOL_HOME}/bin/
AMITOOLS_SOURCE="http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip"
AMITOOLS_TARBALL="/tmp/ec2-ami-tools.zip"
AMITOOLS_BASEDIR="${EC2_AMITOOL_HOME}"
APITOOLS_SOURCE="http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip"
APITOOLS_TARBALL="/tmp/ec2-api-tools.zip"
APITOOLS_BASEDIR="${EC2_APITOOL_HOME}"
if [ ! -d "$EC2_HOME" ]; then
mkdir -p "$EC2_HOME/bin"
mkdir -p "$EC2_HOME/lib"
mkdir -p "$EC2_HOME/certs"
NEW_INSTALL=yes;
fi
#
################################################################################
################################################################################
# AMI tools
#
if [ ! -f ${AMITOOLS_TARBALL} ];then
wget -qO ${AMITOOLS_TARBALL} ${AMITOOLS_SOURCE};
fi
if [ ! -d ${AMITOOLS_BASEDIR} ];then
TMPDIR=$(mktemp -d /tmp/ec2.XXXX)
(cd ${TMPDIR}; unzip -qq ${AMITOOLS_TARBALL})
mv $(ls -1d ${TMPDIR}/ec2-ami-*) ${AMITOOLS_BASEDIR}
rm -fr ${TMPDIR}
cp -a ${AMITOOLS_BASEDIR}/bin/* $EC2_HOME/bin/
cp -a ${AMITOOLS_BASEDIR}/lib/* $EC2_HOME/lib/
fi
################################################################################
# API tools
#
if [ ! -f ${APITOOLS_TARBALL} ];then
wget -qO ${APITOOLS_TARBALL} ${APITOOLS_SOURCE};
fi
if [ ! -d ${APITOOLS_BASEDIR} ];then
TMPDIR=$(mktemp -d /tmp/ec2.XXXX)
(cd ${TMPDIR}; unzip -qq ${APITOOLS_TARBALL})
mv $(ls -1d ${TMPDIR}/ec2-api-*) ${APITOOLS_BASEDIR}
rm -fr ${TMPDIR}
cp -a ${APITOOLS_BASEDIR}/bin/* $EC2_HOME/bin/
cp -a ${APITOOLS_BASEDIR}/lib/* $EC2_HOME/lib/
fi
#
################################################################################
if [ -n "$NEW_INSTALL" ]; then
echo "please add your certificates in $EC2_HOME/certs and update your EC2_PRIVATE_KEY and EC2_CERT"
fi
}