I can not type anything in the terminal Mac Ventura after I type EXIT

Hai Everyone,


I can not type anything in the terminal after I type Exit. the text editor shows:

Last login: Sun Mar  5 22:19:16 on ttys000


Saving session...


...copying shared history...


...saving history...truncating history files...


...completed.




[Process competed]


what should I do to fix it?


I'd tried to restart and also my profile is default.


MacBook Air 13″, macOS 13.2

Posted on Mar 5, 2023 7:33 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 5, 2023 7:52 AM

Luis Sequeira1 wrote:

The default behavior if the base shell program in a window terminates is to close the window

Sadly, what the OP is describing is actually the default behaviour. Anyone who uses Terminal more than three times will immediately change it because it is so annoying. But you did that so long ago that you've forgotten about it.


The fix is hard to find too:

1) Terminal > Preferences/Settings

2) Profiles > Shell

3) Change "When the shell exits" to "Close if the shell exited cleanly"


PS: And if you want to try different "profiles", you'll have to re-apply the fix each time

22 replies
Question marked as Top-ranking reply

Mar 5, 2023 7:52 AM in response to Luis Sequeira1

Luis Sequeira1 wrote:

The default behavior if the base shell program in a window terminates is to close the window

Sadly, what the OP is describing is actually the default behaviour. Anyone who uses Terminal more than three times will immediately change it because it is so annoying. But you did that so long ago that you've forgotten about it.


The fix is hard to find too:

1) Terminal > Preferences/Settings

2) Profiles > Shell

3) Change "When the shell exits" to "Close if the shell exited cleanly"


PS: And if you want to try different "profiles", you'll have to re-apply the fix each time

Mar 5, 2023 7:55 AM in response to etresoft

etresoft wrote:


Luis Sequeira1 wrote:

The default behavior if the base shell program in a window terminates is to close the window
Sadly, what the OP is describing is actually the default behaviour. Anyone who uses Terminal more than three times will immediately change it because it is so annoying. But you did that so long ago that you've forgotten about it.

The fix is hard to find too:
1) Terminal > Preferences/Settings
2) Profiles > Shell
3) Change "When the shell exits" to "Close if the shell exited cleanly"

PS: And if you want to try different "profiles", you'll have to re-apply the fix each time


Thanks. As you said, I probably did this more than a decade ago, so I would not have thought about this...

Mar 9, 2023 6:58 AM in response to muslihati

Quit Terminal.


Open a new Finder Window. That should be in your home folder. Press shift+cmd+. to toggle the hidden dot files to visual. Scroll down in that Finder Window. These dot files will be grayed out but respond to Quick Look (spacebar), the Quick Look panel's default open application, or Finder's secondary Open With choice of text editors.


I would start by using Quick Look. Click once on one of the following and hit the space bar. Inspect each line in the file to determine if the word exit appears in it. If found, then open the plain text file in TextEdit (default for text files in the Quick Look panel) and remove exit, then save the plain text file. In the Quick Look panel, you can also right-click on that Open with TextEdit to choose a preferred alternative plain-text editor.


  • .bash_login, .bashrc, .bash_profile, .bash_logout, .profile
  • .zlogin, .zshrc, .zshenv, .zprofile


Alternatively, you can create a new arbitrarily named folder in your home folder and move each of the listed files into it.


When you are done, relaunch the Terminal application and see if it does not exit on you.

Mar 5, 2023 7:43 AM in response to muslihati

Don't interactively type exit in the Terminal as it ends the current SHELL session and results in a dead Terminal window that cannot receive further user input. Exclude any exit command in any of your SHELL dot files, as that too will terminate the current shell.


Only use exit 0 or exit 1 in a shell script to end the script, either successfully, or with an error condition.

Mar 5, 2023 7:43 AM in response to muslihati

You are not giving us the context of what are executing in terminal.


The exit command (all lowercase!) closes and ends the execution of all the usual shell programs. The default behavior if the base shell program in a window terminates is to close the window, but if that setting has been changed then the behavior you describe seems perfectly correct. You have a window with a shell program to read and execute commands.

Mar 5, 2023 7:40 AM in response to muslihati

I get the same thing.


So I just Close the Terminal Application using the Red Dot in upper Left of the Application window.


I ReLaunch Terminal and can type softwareupdate --list-full-installers and it works as expected


Last login: Sun Mar  5 04:17:49 on console


p.phillips@Ps-Mac-Mini-M1 ~ % exit




Saving session...


...copying shared history...


...saving history...truncating history files...


...completed.


Deleting expired sessions...       4 completed.




[Process completed]



Mar 9, 2023 7:23 AM in response to muslihati

Are you saying that whatever you had done has corrupted your Terminal? And you can't use Terminal at all anymore?


That's pretty common. People copy and paste things they see on the internet and trash their environment.


If what I've described is correct, here is how to get it working again.


In Terminal, choose "New Command" from the "Shell" menu. In the "Command" field, enter the following:


/bin/zsh --no-rcs


This will run the zsh shell with no startup files. It will be a different environment than you are used to, but that's the point. Use this environment to undo whatever you had done to corrupt your environment.


Mar 11, 2023 11:08 AM in response to muslihati

Have you tried @etresoft's suggestion posted earlier in this thread here? In theory this should allow you to access the command line again in order to attempt to fix the issue.


If that fails, then you can either use a text editor to attempt to locate and fix the shell configuration file which has the problem or rename the file so it is no longer used by the shell. To do this you first need to allow the Finder to see the hidden files on the system. Open a Finder window so you are viewing your home user account folder...the home user folder is the one with the house icon on the left pane of the Finder's sidebar which also has your short user name for the account). Then press the following three keys to toggle viewing hidden files on & off:

Shift + Command + Period   (Period is also called the "dot" or look like " . ")


You should now see a few more files in the Finder window including the various shell configuration startup file scripts mentioned by @VikingOSX previously (only if you are viewing the root of the home user folder, other folders may not have hidden items):

@VikingOSX's post dealing with the shell configuration files


If you want to edit the shell configuration file with TextEdit, then right-click (or Control-click) on the shell configuration file within the Finder and select "Open With -->" and select "TextEdit". @VikingOSX's post I just linked contains the possible various shell configuration files which may be there at the root of the home user folder (the folder with the "house" icon on the left pane of the Finder window which also has the short user name of your macOS user account).


Mar 9, 2023 6:29 AM in response to muslihati

So the exit command was inserted in one of the files that your shell executes when it starts.


We need to ascertain which file it is, and to edit it in some other way, outside of the Terminal.


My preferred text editor is TextMate, but we can use BBEdit or even TextEdit (but make sure to keep the file as Plain Text).


In the Finder, press Command-Shift-H to open your home folder, then press Command-Shift-period to show hidden files (they will appear in grey).


Look


for


.zshrc


.bash_profile


or others similarly named.


Control-click, Open With and choose a text editor. Then before making changes post the name of the file and its contents here so we can advise.

Mar 9, 2023 5:54 AM in response to Luis Sequeira1

I plan to install Python using homebrew and pyenv. Pyenv has been successful and the system has been updated to the latest version 3.11.2. but the default python from the macbook has not changed and is still at version 3.9.6. I've typed pyenv global in the shell but it still doesn't change. Finally I followed another way on youtube like this:


pyenv init


then i use nano ~/.zshrc

then I copied eval "$(pyenv init -)" then saved and YES and ENTER


i type pyenv install 3.11.2


#installing process


then I type echo 3.11.2 > ~/.pyenv/version, ENTER

end then EXIT


After that, the terminal appears with the following message, and cannot type anything even I open new terminal or new window.




Last login: Wed Mar  8 22:01:01 on ttys000




Saving session...


...copying shared history...


...saving history...truncating history files...


...completed.




[Process completed]





This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

I can not type anything in the terminal Mac Ventura after I type EXIT

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.