generated from gogolcorp/go-yave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.sh
132 lines (118 loc) · 3.27 KB
/
functions.sh
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
#!/bin/bash
# base64 encode with clipboard copy
function ___base64_encode___() {
STR=$(echo -n "$*" | base64 -w0)
echo "$STR"
echo "$STR" | xclip -sel clip
}
# base64 decode with clipboard copy
function ___base64_decode___() {
STR=$(echo -n "$*" | base64 -d -w0)
echo "$STR"
echo "$STR" | xclip -sel clip
}
# copy the command output
function ___clipboard___ () {
STR=$("$*")
echo "$STR"
echo "$STR" | xclip -sel clip
}
# delete all Docker ressources
function ___docker_purge___() {
sleep 1; clear; echo -e "\e[33m[#] ANNIHILATION IN 3 [#]\e[0m"
sleep 1; clear; echo -e "\e[33m[#] ANNIHILATION IN 2 [#]\e[0m"
sleep 1; clear; echo -e "\e[31m[#] ANNIHILATION IN 1 [#]\e[0m"
sleep 1; clear; echo -e "\e[1;33;41m[!] I G N I T I O N [!]\e[0m"
sleep 1; clear; echo -e "\e[34m[1] STOPING CONTAINERS [1]\e[0m"
docker stop $(docker ps -a -q)
sleep 1; clear; echo -e "\e[34m[2] REMOVING CONTAINERS [2]\e[0m"
docker rm $(docker ps -a -q)
sleep 1; clear; echo -e "\e[34m[3] REMOVING IMAGES [3]\e[0m"
docker rmi $(docker images -q)
sleep 1; clear; echo -e "\e[34m[4] REMOVING VOLUMES [4]\e[0m"
docker system prune --all --volumes --force
sleep 1; clear; echo -e "\e[32m[5] SHOW OUTPUT [5]\e[0m"
docker ps -a ; docker images
sleep 1; clear; echo -e "\e[1;33;42m[<] ANNIHILATION DONE [>]\e[0m"
return
}
# find a specific string in environment variables
function ___find_in_aliases___ () {
alias | grep "$*"
}
# find a specific string in environment variables
function ___find_in_env___ () {
env | grep "$*"
}
# find a specific string in zsh/bash history
function ___find_in_history___ () {
history | grep "$*"
}
# config git profile for specific workspace
function ___git_config___ () {
if [ "$1" = "pro" ] ; then
git config user.name "alexandre.delaloy"
git config user.email "alexandre.delaloy@alteia.com"
echo "git configured [alexandre.delaloy@alteia.com]"
else
git config --global user.name "blyndusk" & git config --global user.email "alexandre.delaloy.pro@gmail.com"
echo "git configured [alexandre.delaloy.pro@gmail.com]"
fi
}
function ___git_sync___ () {
git fetch origin
if git branch -l | grep -q "master"; then
git checkout master
else
git checkout main
fi
git pull
}
# run Goeland soft
function ___goeland___() {
cd "$(find ~/go/src/ -type d -name "go-eland" | head -n 1)" || exit
make run
}
# make directory then change into it
function ___mkdir_cd___() {
mkdir -p "$@"
cd "$_" || exit
return
}
# open file explorer with given folder
function ___open_fe___() {
if [ $# -eq 0 ] ; then
xdg-open .
else
xdg-open "$@"
fi
return
}
# open VSCode with given folder
function ___open_vscode___() {
if [ $# -eq 0 ] ; then
code .
else
code "$@"
fi
return
}
# de-sops template
function ___super_sops___() {
sops -d $1.sops.yaml | gomplate -d "main-config=merge:platform|main" -d main=main-config.yaml -d platform=stdin:///platform.yaml -f ./values.yaml.tpl -o ./values.yaml
}
function ___alteia_ctx___() {
if [ "$1" = "d" ]; then
kubectx Alteia-dev
elif [ "$1" = "s" ]; then
kubectx Alteia-staging
elif [ "$1" = "p" ]; then
kubectx Alteia-prod
elif [ "$1" = "ges" ]; then
kubectx GE-preprod
elif [ "$1" = "gep" ]; then
kubectx GE-prod
else
echo "Invalid flag."
fi
}