-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.functions
113 lines (106 loc) · 3.12 KB
/
.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
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
#############################################################
# general
############################################################
bump_dot_files () {
if [ -z "$1" ]
then
echo "Please provide a commit message"
return
fi
cd "${HOME}/repos/mikeewhite/dotfiles"
git add .
git commit -m "$1"
git push origin master
cd $cwd
}
###############################################################
# iTerm
###############################################################
# Switches the current profile
# Usage: iterm_profile <profile-name> (case-sensitive)
iterm_profile() {
echo -e "\033]50;SetProfile=$1\a"
}
# Changes the title of the current tab
iterm_title() {
echo -ne "\033]0;"$*"\007"
}
###############################################################
# git
###############################################################
git-branch() {
if [ -z "$1" ]
then
echo "Please provide a branch name (note: this will be prefixed with 'mikeewhite/')"
return
fi
git checkout -b mikeewhite/$1 origin/master
}
###############################################################
# github
###############################################################
github() {
if [ ! -d .git ] && ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "ERROR: This isnt a git directory" && return false
fi
git_url=$(git config --get remote.origin.url)
if [[ $git_url == https://gitlab* ]]; then
url=${git_url%.git}
elif [[ $git_url == https://github* ]]; then
url=${git_url%.git}
elif [[ $git_url == git@gitlab* ]]; then
url=${git_url:4}
url=${url/\:/\/}
url="https://${url%.git}"
elif [[ $git_url == git@github* ]]; then
url=${git_url:4}
url=${url/\:/\/}
url="https://${url%.git}"
elif [[ $git_url == git://github* ]]; then
url=${git_url:4}
url=${url/\:/\/}
url="https://${url%.git}"
else
echo "ERROR: Remote origin is invalid" && return false
fi
open $url
}
###############################################################
# grpc
###############################################################
# Starts a grpc-ui session (see https://github.com/fullstorydev/grpcui)
# Usage: grpc <port>
grpc () {
grpcui -plaintext localhost:$1
}
###############################################################
# k8s
###############################################################
# Starts an interactive bash session on a container running on a k8s pod
# Usage: k8s_bash <pod-name> <container-name>
k8s_bash () {
if [ -z "$1" ]
then
echo "Please provide a pod name. Usage: k8s_bash <pod-name> <container-name>"
return
fi
if [ -z "$2" ]
then
echo "Please provide a container name. Usage: k8s_bash <pod-name> <container-name>"
return
fi
set -x
kubectl exec -it $1 --container=$2 -- /bin/bash
}
##############################################################
# rabbitmq
##############################################################
# Taps an exchange using https://github.com/jandelgado/rabtap
tap () {
if [ -z "$1" ]
then
echo "Please provide an exchange name, e.g. tap notifications"
return
fi
rabtap tap $1: --uri amqp://localhost:5672/
}