typewriter() {
    # Check if an argument is provided
    if [ $# -eq 0 ]; then
        echo "Usage: typewriter <text>" >&2
        return 1
    fi

    local text="$1"
    local len

    # Get length of string in characters (not bytes)
    len=$(echo -n "$text" | wc -m)

    # Iterate through each character using AWK
    echo -n "$text" | awk '{
        split($0, chars, "")
        for (i = 1; i <= length($0); i++) {
            printf "%s", chars[i]
            system("sleep 0.05")
            fflush()
        }
    }'
    echo
}