-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_bash_functions.tmpl
61 lines (54 loc) · 1.66 KB
/
dot_bash_functions.tmpl
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
# Copyright (C) © 🄯 2023-2024 James Cuzella
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
# Convert a unix timestamp to a readable format (like date12h in .bash_aliases)
dateFromEpoch()
{
#date +'%a %b %d %I:%M:%S %p %Z %Y' -d "@${1}"
date -r "${1}"
}
instance_info()
{
local profile_cmd="";
if ( echo $1 | egrep -q -- '^i-' ); then
local instances=$*;
else
local profile_cmd="--profile=$1";
shift 1;
local instances=$*;
fi;
aws ${profile_cmd} --output=text ec2 describe-instances --instance-ids ${instances} | awk '$1~/^INSTANCES|TAGS/ {
if ($1~/INSTANCES/) print "\nInstanceId:", $8;
else if ($1 ~/TAGS/) print $2":", $3;
}'
}
dockerterm()
{
CONTAINER=$1
docker exec -it $CONTAINER bash
}
{{ if eq .chezmoi.os "darwin" -}}
sha256()
{
shasum -a 256 "$1" | awk '{ print $1 }' | pbcopy
}
pidport() {
lsof -n -i4TCP:$1 | grep LISTEN
}
{{ end -}}
{{ if eq .chezmoi.hostname "lyra" -}}
fuck-it()
{
for h in ComputerName LocalHostName HostName ; do sudo scutil --set $h lyra; done
}
{{ end -}}