Each time I open Terminal, I get an error:
/Users/myname/.zsh_sessions/SESSIONID.session:2: command not found: Saving
in each of the windows I set to open by default. This seems to have appeared a week ago possibly with an OS update (Monterey)
I haven't touched anything in Terminal though.
This seems to be related to an error in the way the session file SESSIONID.session is written in /Users/myname/.zsh_sessions/ when quitting Terminal
(blank line)
Saving session...echo Restored session: "$(/bin/date -r 1699309069)"
(blank line)
Maybe a bug in etc/zshrc_Apple_Terminal or a configuration problem
Any idea?
EDIT:
I commented out the echo -ne line in etc/zshrc_Apple_Terminal and the problem disappeared
shell_session_save() {
# Save the current state.
if [ -n "$SHELL_SESSION_FILE" ]; then
# echo -ne '\nSaving session...' >&2
(umask 077; echo 'echo Restored session: "$(/bin/date -r '$(/bin/date +%s)')"' >| "$SHELL_SESSION_FILE")
/etc/bashrc_Apple_Terminal. Session save/restore has been in Terminal.app forever. What changed??? Do all of us seeing it has something similar (but not default) in our setups? Python? Homebrew? VS Code? … – Andrew Jaffe Nov 08 '23 at 06:20shell_session_savefrom the command line. To make this echo in the end produce that error, it means that some process must collect the standard error of that function and execute it as command. – user1934428 Nov 08 '23 at 10:08$SHELL_SESSION_FILEwhile the following(…)subshell is running; that file is then run (as it should) on the restart of Terminal.app, but with these incorrect characters in it. – Andrew Jaffe Nov 08 '23 at 10:11>|of the subsequent line would recreate the session file. I simply don't see how this effect can be achieved by the code posted here. – user1934428 Nov 08 '23 at 10:18echoline byprint -u 2 $'\nSaving session ...', and then see whether the error is the same. Or maybe doing aecho .... >$(tty)instead. The latter really should not be redirected to any file, even if FD 2 is messed up somehow. – user1934428 Nov 08 '23 at 10:21trap shell_session_update EXIT, and the error seems to occurs only when the terminal exits because the Terminal.app is quit, but not by an explicitexitcommand (nor when various signals are sent by hand to the shell, either). – Andrew Jaffe Nov 08 '23 at 10:43