I'm trying to migrate from bash to fish.

What is the fish's analog to shopt? I'm trying to imitate this line from my .bashrc:

shopt -s dotglob # for mv * see hidden files
  • Pretty sure there isn't one. the documentation talks about dot files not being included with no mention about any configuration mechanism. You'll probably have to glob with {,.}* manually. – glenn jackman Jan 2 '14 at 18:14
  • 1
    Note, you may want to ask on stackoverflow.com, some of the fish maintainers hang out there. – glenn jackman Jan 6 '14 at 18:39

This is intentional. Most of time the users don't want to accidentally match the hidden files that are invisible for ls (without -a). Usually, files are hidden for a reason, not just to troll you. Also, if * would match hidden files, matching non hidden files would be too tricky.

However, unlike bash shopt -s dotglob is not needed to match hidden files. In bash, shopt -s dotglob is the only way of matching every file in the directory without accidentally matching . or ... However, fish shell can never match . or .. with globs, therefore that's not an issue (if you seriously need to match . or .. for some silly reason, just say them explicitly). Besides, fish tries to avoid having options by design, so it doesn't have dotglob.

To match every single file in the directory, you may want to use bracket expansion to detect files starting with dots, and those which aren't. {.,} is bracket expansion which matches dot that may or may not exist. The star after it matches everything. Because globs in fish cannot match . or .., the following code matches everything except for those two directories (which bash sadly matches, if you use the code below)

cat {.,}*
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.