I typed () in terminal and got a prompt. What is it for?

Solution 1:

Zsh allows anonymous functions, which are executed right on the spot. For instance

() {
echo $1 $1 $1
} X Y

prints X X X. The main use in shell scripts is for having a piece of code where you want to define variables locally, without affecting the rest of your program. I don't see any pratical use for it in interactive shells, but if you do, the function prompt serves to remind you, that you are now inside a function definition.