When I write multi-line statements in interactive mode in Zsh, it will prefix my statements with the block type I'm in like so:
% for i in $(seq 3); do
for> echo $i
for> done
1
2
3
% function foo() {
function> echo bar
function> }
% foo
bar
I prefer not to see for>
and function>
and other code block prefixes. I'm not even sure what these prefixes are called to adequately search for how to suppress them. Bash does this too with just the >
character, but I've not had luck figuring it out from that route. Is there a way to disable these in Zsh?
--EDIT--
Turns out the default $PS2
value in Zsh is PS2=%_>
, for anyone that comes across this via a search engine someday. From the docs:
%_
The status of the parser, i.e. the shell constructs (like ‘if’ and ‘for’) that have been started on the command line. If given an integer number that many strings will be printed; zero or negative or no integer means print as many as there are. This is most useful in prompts PS2 for continuation lines and PS4 for debugging with the XTRACE option; in the latter case it will also work non-interactively.
Based on the accepted answer, I wound up with my PS2 set like this, which adds a 2 space indent to each block, and accounts for an initial 2 spaces to align with my PS1 length:
PS2='${${${(%):-%_}//[^ ]}// / } '