# zls () {
# simple internal ls using the stat module

zmodload -i zsh/stat || return 1

emulate -R zsh
setopt localoptions

local f opts='' L=L mod=: dirs list
typeset -A stat

dirs=()
list=()

while getopts ailLFdtuc f
do
    opts=$opts$f
    if [[ $f == '?' ]] then
	echo Usage: $0 [ -ailLFd ] [ filename ... ]
	return 1
    fi
done
shift OPTIND-1rgv[i, '' -K multicomp
# )
pref="${pref#:}"

sofar=('')
reply=('')

if [[ "$pref" = \~* ]]; then
  # If the string started with ~, save the head and what it will become.
  origtop="${pref%%/*}"
  eval "newtop=$origtop"
  # Save the expansion as the bit matched already
  sofar=($newtop)
  pref="${pref#$origtop}"
fi

while [[ -n "$pref" ]]; do
  [[ "$pref" = /* ]] && sofar=(${sofar}/) && pref="${pref#/}"
  head="${pref%%/*}"
  pref="${pref#$head}"
  [[ -z "$pref" ]] && globdir=
  # if path segment contains wildcards, don't add another.
  if [[ "$head" = *[\[\(\*\?\$\~]* ]]; then
    wild=$head
  else
    # Simulate case-insensitive globbing for ASCII characters
    wild="[${(j(][))${(s())head:l}}]*"	# :gs/a/[a]/ etc.
    # The following could all be one expansion, but for readability:
    wild=$wild:gs/a/aA/:gs/b/bB/:gs/c/cC/:gs/d/dD/:gs/e/eE/:gs/f/fF/
    wild=$wild:gs/g/gG/:gs/h/hH/:gs/i/iI/:gs/j/jJ/:gs/k/kK/:gs/l/lL/
    wild=$wild:gs/m/mM/:gs/n/nN/:gs/o/oO/:gs/p/pP/:gs/q/qQ/:gs/r/rR/
    wild=$wild:gs/s/sS/:gs/t/tT/:gs/u/uU/:gs/v/vV/:gs/w/wW/:gs/x/xX/
    wild=$wild:gs/y/yY/:gs/z/zZ/:gs/-/_/:gs/_/-_/:gs/[]//

    # Expand on both sides of '.' (except when leading) as for '/'
    wild="${${wild:gs/[.]/*.*/}#\*}"
  fi

  reply=(${sofar}"${wild}${globdir}")
  reply=(${~reply})

  [[ -z $reply[1] ]] &