From 38bab29776950ac2364ed64195b89887717c33de Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Thu, 1 Jan 1970 03:00:00 +0300 Subject: chore: init --- profile/.profile.d/90_functions.sh | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 profile/.profile.d/90_functions.sh (limited to 'profile/.profile.d/90_functions.sh') 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 -- cgit 1.4.1