You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Can't escape from Pico in Terminal

I started inputting some information into Terminal. At a certain point, I didn't have the result I wanted and wanted to make some changes. However, it seems I became stuck in the program PICO, which, as I understand is a word processor of some sort in Terminal. There are commands shown at the bottom of the Terminal window, within Pico, one of which is crtl X, which should allow me to exit from Pico to go back into the regular Terminal window; it doesn't work. If I close Terminal and restart it, for a split second, I can see the regular window before Pico takes over. If I restart in Recovery mode, then I can use a regular Terminal, but I cannot make any changes to try to erase any data connected to Pico. When I then restart the computer again, Pico is back in Terminal. I tried iTerm and another 'Terminal-like' program, but both of these had the same Pico within and I could not escape it. I want to escape Pico and get back to the normal Terminal window.

iMac (2017 – 2020)

Posted on Jan 20, 2025 5:13 AM

Reply
11 replies

Jan 20, 2025 7:23 AM in response to narutojp

PICO is a sub-process owned by Terminal. Click on the Terminal window and press cmd+Q to Quit Terminal. You will see this dialog on which you click Terminate:



Stop using Pico. I recommend that you download the free 30-day trial of BBEdit which is a proper text editor. Upon conclusion of the trial period, the application becomes free to use without some of its more advanced features. You won't need to remember or deal with Pico's control characters or be trapped in Pico again.


You can get BBEdit from the Mac App Store for free. It does have in-app purchases which you can ignore and once the free trial period is over, it becomes a free editor without some of its more advanced features.


Here is the direct PDF download link for the BBEdit 15 User Manual.

Jan 20, 2025 7:56 PM in response to narutojp

No matter what, you should be able to press Control + X to bring up the prompt to confirm saving any changes. I don't know why that part is not working.


It sounds like you modified a shell profile so that it is launching nano/pico whenever you launch a Terminal session. Plus the nano/pico titlebar shows you were trying to modify a shell configuration file ".bashrc"....perhaps you did the same for Zsh?


While booted into your macOS user account, make sure to completely Quit the Terminal app. Then open a Finder Window showing your home user folder (Finder "Go" menu & select "Home"). Then toggle the Finder view to show hidden items by using Shift + Command + Dot/Period. You can see the normally hidden shell configuration files. Rename the file using the Finder (best to just add "--bak" to indicate a backup of that file) just in case you need to retain some custom settings.


You can just press Shift + Command + Dot/Period again with an open Finder window to hide the hidden items again.


It is also possibly you may need to delete the shell Session files/folder as they are used to restore your Terminal to have it reopen all the Terminal windows & tabs.


It is possible to edit that file while booted into Recovery Mode, but you have to know how to navigate to that location. I'm not providing that information here since it seems you may not be that comfortable/experienced with the command line so I don't want to have you risk more problems when you can achieve the same results while booted into your macOS user account using the Finder where you are less likely to make a mistake.


FYI, I hope you have frequent and regular backups of your computer so that you can restore your account to before you accidentally made the accidental change here. The command line is very unforgiving with no safety nets, so you need to proceed carefully and it is best to make a local backup of any files you are going to edit in order to make it easier to revert the changes.

Jan 20, 2025 10:06 PM in response to HWTech

Thank you!! Finding the hidden files and renaming them worked. After renaming those two files, I restarted Terminal and I was once again back to a clean slate. And, thank you for your concern and suggestions; I do use Time Machine, so it would have been possible to go back in time. I also considered a reinstall of the OS, but hoped I could find another solution before then. Cheers!

Jan 21, 2025 8:41 PM in response to VikingOSX

^X in pico should also map to fn-F2. Out of curiosity, does fn-F2 work to exit pico on Sequoia 15.2? if not...^X isn't actually the exit command - it's the "flush the buffer then exit" command, so I would have to wonder if something is preventing the buffer form being written, or if the buffer is being written but the program isn't exiting.

Jan 21, 2025 9:00 PM in response to narutojp

Aside from the issues with pico, which others are already addressing...what are you trying to do with your .bashrc file?


Normally one doesn't launch the terminal and bring up a bash interactive shell only to have the bash config file that gets loaded in an interactive shell launch another bash in non-interactive mode (which is usually only invoked in shell scripts). I can't imagine why one would do that and then also try to do the same with a zsh shell.


I'm not actually sure what would happen in this case...invoking "bash --noprofile --norc" directly from the commandline just launches an interactive bash with no configurations set at all. If that is the case from inside .bashrc, then .bashrc cannot be loaded because the bash startup would hang until the invoked bash interactive shell exits(?)


I have to wonder if bash isn't just throwing up over itself and invoking pico on .bashrc when the shell fails because for some reason pico is your default $EDITOR...


Something is definitely weird with what you appear to be (maybe unintentionally) doing.

Can't escape from Pico in Terminal

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