blob: b06337fdbefdeb87bef533631339f0be3211ca91 (
plain) (
blame)
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
|
snippet ssh "safe shell optsions"
set -euo pipefail
endsnippet
snippet scriptdir "get script directory"
scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
endsnippet
snippet getopts
while getopts ":h" opt; do
case "${opt}" in
h)
help
;;
*)
usage
;;
esac
done
shift $((OPTIND - 1))
endsnippet
snippet die
die() {
echo "\$1" >&2
exit 1
}
endsnippet
snippet psql
psql --no-psqlrc --quiet -v ON_ERROR_STOP=1
endsnippet
snippet psqlq
psql --no-psqlrc --quiet --no-align --tuples-only
endsnippet
snippet usage
echo "Usage: ${0##*/}"
endsnippet
snippet colors
GREEN='\033[0;32m'
RED='\033[0;31m'
RESET_COLOR='\033[0m'
echo -e "${GREEN}Yay!${RESET_COLOR}"
echo -e "${RED}Error!${RESET_COLOR}"
endsnippet
snippet green
echo -e "${GREEN}${1}${RESET_COLOR}"
endsnippet
snippet red
echo -e "${RED}${1}${RESET_COLOR}"
endsnippet
snippet main
main() {
$0
}
main "$@"
endsnippet
|