about summary refs log tree commit diff
path: root/profile/.profile.d/90_functions.sh
blob: a5b63ec1590894431a44eddb42654510babd85be (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
#!/bin/sh

count() {
	printf "%d\n" "${#}"
}

dec2hex() {
	printf "0x%X\n" "${1}"
}

hex2dec() {
	printf "%d\n" "0x${1}"
}

ff() {
	find . -type f -iname "${@}" -ls
}

mkcd() {
	mkdir -p "${1}" &&
		builtin cd "${1}" ||
		return
}

mvcd() {
	mv -i -- "${PWD}" "${1}" &&
		builtin cd . ||
		return
}

cald() {
	printf "\t\t%s\n\n" "$(date)" && cal -m -3
}

cheat() {
	curl "cheat.sh/${1}"
}

myip() {
	dig -4 +short @resolver1.opendns.com myip.opendns.com A
}

myip6() {
	dig -6 +short @resolver1.opendns.com myip.opendns.com AAAA
}

if ! command -v sponge >/dev/null 2>&1; then
	sponge() {
		_tmp="$(mktemp)" || return 1

		cat >"${_tmp}"
		cat -- "${_tmp}"
		rm -f -- "${_tmp}"

		unset _tmp
	}
fi

Consider giving Nix/NixOS a try! <3