How to include hidden files in ls pattern match?

I was just trying to list files in the current directory with a certain pattern, but it doesn't work with hidden files. How can I match all the files?

I tried

ls *foo*

and

ls -a *foo*

Not finding anything in Google, the keywords I can think of to search for this lead to a lot of unrelated informations...


Solution 1:

Enable globbing for hidden files:

shopt -s dotglob
ls *foo*

Disable:

shopt -u dotglob

Show globbing status:

shopt dotglob