diff options
author | Azat Bahawi <azat@bahawi.net> | 1970-01-01 03:00:00 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2022-09-20 11:51:54 +0300 |
commit | 38bab29776950ac2364ed64195b89887717c33de (patch) | |
tree | edaaf366a55dbe96d268019124536bc504c64e87 /profile/.profile.d/90_functions.sh |
Diffstat (limited to '')
-rw-r--r-- | profile/.profile.d/90_functions.sh | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/profile/.profile.d/90_functions.sh b/profile/.profile.d/90_functions.sh new file mode 100644 index 0000000..a5b63ec --- /dev/null +++ b/profile/.profile.d/90_functions.sh @@ -0,0 +1,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 |