-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_functions
74 lines (64 loc) · 2.43 KB
/
.bash_functions
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
function title {
echo -ne "\033]0;"$*"\007"
}
function alphanumpassword {
local length=${1:-53}
cat /dev/random | LC_ALL=C tr -dc "[:alnum:]" | tr "[:upper:]" "[:lower:]:" | head -c $length;
}
function recur-in-git {
echo "Running git $@ recursively"
local directories=$(find . -type d -depth 2 -name .git | xargs -n 1 dirname)
for directory in $directories; do
echo "###################################################################";
echo "Running git $@ in $directory"
echo "###################################################################";
pushd $directory > /dev/null 2>&1;
$@;
popd > /dev/null 2>&1;
done
}
function git-recur {
echo "Running git $@ recursively"
local directories=$(find . -type d -depth 2 -name .git | xargs -n 1 dirname)
for directory in $directories; do
echo "###################################################################";
echo "Running git $@ in $directory"
echo "###################################################################";
pushd $directory > /dev/null 2>&1;
git $@;
popd > /dev/null 2>&1;
done
}
function npm-recur {
echo "Running npm $@ recursively"
local directories=$(find . -type f -depth 2 -name package.json | xargs -n 1 dirname)
for directory in $directories; do
echo "###################################################################";
echo "Running npm $@ in $directory"
echo "###################################################################";
pushd $directory > /dev/null 2>&1;
npm $@;
popd > /dev/null 2>&1;
done
}
function aws_ip_from_private_dns_name() {
echo $(aws ec2 describe-instances --filters "{\"Name\":\"private-dns-name\", \"Values\":[\"$1*\"]}" --query='Reservations[0].Instances[0].PublicIpAddress' ) | tr -d '"'
}
function k_describe_node_for_pod() {
kubectl describe node $(kubectl get pods $1 -owide --no-headers | awk '{ print $7 }')
}
function k_kibana() {
kubectl port-forward $(kubectl get pods -lapp=aws-es-proxy -o jsonpath="{.items[0].metadata.name}") 9200 &
sleep 3
open "http://localhost:9200/_plugin/kibana/"
fg
}
# Used by bash-git-prompt
function prompt_callback {
echo " $(kube_ps1)"
}
function ecr-docker-login() {
eval $(aws ecr get-login --no-include-email)
}
function aws-start-session() { eval $( mfa-start-session $@); }
function aws-assume-role() { eval $( assume-role $@); }