`ls` indicates when directory is empty/full of dotfiles
Portability issues

The function collects the given options and when it finally calls ls,
it puts the options at the end.
Unfortunately this doesn't work on OSX,
where the options must come before the filenames.

Your remarks


  
  seems over-complicated
  


Yes. Unfortunately, to get the behavior that you want,
I don't think this can get much simpler.


  
  non-perfect handling of some ls options, notably -l in case of only-dotfiles directory (print total 0)
  


Unfortunately, the only way to avoid that will only make the script even more complicated.


  
  if a directory contains only dot files, the ls command is runned twice. Could be costly if the directory contains a lot of dot files.
  


Perhaps you forgot to count the 2 runs of command ls in the if-else chain.
So in fact for each file the ls command is executed 4 times.

Filenames with spaces

This will not work when the filenames have spaces:


ls_filepaths="$ls_filepaths $filepath"



You can make it work with filenames with spaces,
and at the same time cleaner,
by using arrays.

"Remove options surrounding spaces"

I'm not sure what's going on here:


# remove options surrounding spaces
ls_options=$(echo "$ls_options" | tr -d "[:space:]")



For example -l -a would become -l-a which will not work.

Avoid negatives in variable names

It's generally not recommended to use negatives in variable names like isnotfirst,
because it could lead to strange conditions like not isnotfirst,
which is hard to read and confusing.
I suggest to rename it to first and use ! "$first" in conditions for a negative meaning.

Terminology


# Wrapper around ls function, printing dedicated messages



ls is not a "function", it's a command.
For example, verbosels is a function.

Looping over "$@"

When looping over "$@",
you can omit the "$@".
So instead of this:


for parameter in "$@"; do



You can write simply:

for parameter; do


Pattern matching

Instead of matching by regular expressions like this:


if [[ "$parameter" =~ ^-.* ]]; then



It would be slightly simpler to use pattern matching like this:

if [[ "$parameter" == -* ]]; then


Setting a variable to empty

Instead of this:


ls_options=""
ls_filepaths=""



You can simplify as:

ls_options=
ls_filepaths=


echo is the same as echo ""

You can replace echo "" with simply echo with no parameters.