-
Notifications
You must be signed in to change notification settings - Fork 0
/
.functions
86 lines (70 loc) · 1.55 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
#!/bin/bash
function gocover () {
t="/tmp/go-cover.$$.tmp"
go test -v -coverprofile=$t $@ && \
go tool cover -html=$t && \
rm $t
}
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$_";
}
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh;
else
local arg=-sh;
fi
if [[ -n "$@" ]]; then
du $arg -- "$@";
else
du $arg .[^.]* ./*;
fi;
}
###################### K8S functions ######################
function getJobs(){
kubectl get jobs -n $1
}
function deleteJob(){
kubectl delete job -n $1 $2
}
function getPods() {
kubectl get pods -n $1
}
function getLogs(){
kubectl logs -f -n $1 $2
}
function getServices() {
kubectl get services -n $1
}
function getDeploy() {
kubectl get deploy -n $1
}
###################### Git functions ######################
function updateBranch() {
git fetch --all
git reset --hard FETCH_HEAD
git pull
}
function gitsync() {
git checkout $1;
git remote prune origin;
git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D;
git checkout -
}
function gstash() {
git stash push -m "$1"
}
function gstashapply() {
git stash apply $(git stash list | grep "$1" | cut -d: -f1)
}
function gstashpop() {
git stash pop $(git stash list | grep "$1" | cut -d: -f1)
}
function gstashdrop() {
git stash drop $(git stash list | grep "$1" | cut -d: -f1)
}
function tre() {
tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
}