diff options
Diffstat (limited to 'profile/.profile.d/90_functions.sh')
-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 |