The problem likely is with one of the three following files all located at the root of your home directory: .bashrc, .profile, or .bash_profile. Try this:
1) While in an sh session, navigate to your home directory if you are not already there (type in cd ~).
2) Run the command ls -al and determine which of those files (.bashrc, .profile, or .bash_profile) are present in your home folder.
3) It is likely the file which is causing the problem is the last one you were editing or is linked to by one of the three previously named files. Either move or change the file name of one of those files in of your home directory. If you are not sure which file you were working with, I would start with .bashrc.
Example command to move .bashrc: mv .bashrc bashrc.bak
4) Once you have moved or changed the file name of one of the previously listed files, try opening a new bash session. If the session launches successfully, then you know which file needs to be edited further. If the bash session does not launch, restore the file back to its original location. If no one file appears to be the cause, try moving or changing the file names of all named files.
5) Make a backup of the file which is causing problems.
To resolve the "process completed" message, you will need to troubleshoot the script looking for return or exit statements which may be written incorrectly. If those are not present, you may have to go the route of commenting lines of the script out to determine where the problem is. To comment a line out, add a # character to the beginning of the line.
During this last step, you will need to move a copy of the offending file back to its original location. To make things easier, I would probably open the file using TextWrangler or from nano or vim in another sh session to make changes.
(Note: TextEdit and XCode will also work. However, to open the file, you will need to issue a command such as "open -a TextEdit.app ~/.bashrc" to open the file because the Open File Window does not allow for opening files whose names start with a period.)
Best Answer
This can be done with the standard unix command
script(1)
though requires running a subshell under the current shell. That is, start a terminal, and runscript
, issue whatever commands need to be logged, then exit from that shell:Then in the output
typescript
file there should be a record of the shell session run underscript(1)
.But wait, there's more! With
expect
one can also save a session and possibly replay it. This requires installingexpect
from a ports system (Fink, Homebrew, or here MacPorts) which should installautoexpect
:Doing something useful with
script.exp
in turn probably requires knowledge ofexpect
and TCL, so this is a more advanced option. (expect
in particular has alog_file
option that can be toggled to save everything, but then you'd be writing everything in TCL and notbash
...)Otherwise the terminal itself must save the session;
iTerm.app
probably has more options for this (Session -> Log -> Start) thanTerminal.app
.