function where() { local s s="$(type -P "$1")" realpath "$s" } complete -F _command where function what() { local s s="$(where "$1")" printf "%s\n" "${s%/*/*}" } complete -F _command what function cat() { if (($# == 1)) && [[ -d $1 ]]; then ll "$1" else command cat "$@" fi } function cd() { builtin cd "$@" && if ((${#FUNCNAME[@]} == 1)); then ls fi } function mkcd() { mkdir -p "$1" && builtin cd "$1" } function mvcd() { mv -i -- "$PWD" "$1" && builtin cd . } function bak() { local f for f; do cp -ai -- "$f" "$f.bak" done } function ubak() { local f for f; do [[ $f == *.bak ]] || f="$f.bak" mv -i -- "$f" "${f%.bak}" done } function dec2hex() { printf "0x%X\n" "$1" } function hex2dec() { printf "%d\n" "0x$1" }