14

What does the caret ^ do in zsh? echo ^ lists the files in the current directory, like ls. I use grml.

Apparently it is not an alias and which ^ prints the same as which $(ls). Also command -v ^ prints nothing and returns 1.

Can I assume ^ behaves like a variable containing files in current dir?

1 Answer 1

15
$ PS1='%% ' zsh -f
% print ^
^
% setopt EXTENDED_GLOB
% print ^
...
% 

So, you must have EXTENDED_GLOB enabled, and therefore the ^ is a glob, so after digging through zshexpn(1) we find

   ^x     (Requires EXTENDED_GLOB to be set.)  Matches anything except the
          pattern x.  This has a higher precedence than `/', so `^foo/bar'
          will  search  directories in `.' except `./foo' for a file named
          `bar'.

So "everything except x" matches everything, as you did not exclude anything with a blank x.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .