9 Replies Latest reply: Jun 22, 2010 11:22 PM by Mike M 3998
supergeek66 Level 1 Level 1 (0 points)
So I was reading online about how to make Terminal run a command on startup. When entering the commands to make it run a command on the start of Terminal I guess I messed up, now whenever I start Terminal it says [Process Completed] and wont let me enter any more commands. It also does this when I open a new shell. I want to know if there is a way to delete this startup command so Terminal opens as it does out of the box.

Mac OS X (10.6.3)
  • BobHarris Level 6 Level 6 (15,385 points)
    I assume you are talking about a file with a name such as .profile, .bashrc, .bash_profile, etc... That is to say a file start starts with a dot (aka period).

    You can use a utility such as Onyx
    <http://www.versiontracker.com/dyn/moreinfo/macosx/20070>
    Onyx -> Parameters -> Finder -> [X] Show hidden files and folders

    The Finder should now show you the .profile, .bashrc, .bash_profile, etc... file or files in your home directory. You can now delete the offending file.

    Then use Onyx to hide those files again.

    If you were talking about Terminal -> Preferences -> Startup -> Command, then you can delete
    /Users/yourusername/Library/Preferences/com.apple.Terminal.plist

    Message was edited by: BobHarris
  • Tony T1 Level 6 Level 6 (8,780 points)
    The following Applescript will also show (and hide) the hidden files in Finder:

    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #E6E6EE;
    overflow: auto;"
    title="this text can be pasted into the AppleScript Editor">

    set answer to the button returned of (display dialog ("Finder Hidden Files:") buttons {"Show", "Hide", "Cancel"} with icon caution default button 3 with title "Finder Hidden Files")
    if answer is "Show" then
    tell application "Finder" to quit
    do shell script "defaults write com.apple.finder AppleShowAllFiles 1"
    delay 2
    tell application "Finder" to run
    else
    tell application "Finder" to quit
    do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
    delay 2
    tell application "Finder" to run
    end if</pre>
  • supergeek66 Level 1 Level 1 (0 points)
    Is there a way to figure out which file is the offending file. The computer I am using is a shared computer with many users. When Terminal opens in a different user it responds normally so the offending file is within my user. If you could give me a list of files that might be the bad one that would be great.
  • BobHarris Level 6 Level 6 (15,385 points)
    Is there a way to figure out which file is the offending file. The computer I am using is a shared computer with many users.

    If you DID NOT touch files in /etc, then the files are specific to your account.
    When Terminal opens in a different user it responds normally so the offending file is within my user. If you could give me a list of files that might be the bad one that would be great.

    What file did you create?

    It will most likely start with a dot.

    A lot depends on what shell you are using. bash is the default, but there are other shells, such as sh, ksh, zsh, csh, and tcsh

    Possible names are, and there could be more

    .profile
    .bash_profile
    .bash_login
    .bashrc
    .login
    .cshrc
    .tcshrc
    .kshrc
    .zshrc
    .zshenv
    .zprofile
    .zlogin
  • Mark Jalbert Level 5 Level 5 (4,595 points)
    Or this shell script->

    #!/bin/sh

    #showallfiles

    # Description and usage message
    usage () {
    echo "
    Description:
    A simple shell script to reveal/conceal files
    hidden in Mac OS X Finder application.
    showallfiles excepts one option.

    Usage: ${0##*/} [-h|--help] to show this help
    ${0##*/} [on|ON] to show hidden files
    ${0##*/} [off|OFF] to set the default hidden files

    Example: ${0##*/} on

    "
    }

    # Test for more than one option
    if [ $# -gt 1 ]
    then echo "${0##*/} -h to access help"; exit
    fi

    # Get the AppleShowAllFiles status in the domain com.apple.finder.plist or create the default off setting
    STATUS=`defaults read com.apple.finder AppleShowAllFiles 2>/dev/null` || STATUS=`defaults write com.apple.finder AppleShowAllFiles OFF`

    # Function to check AppleShowAllFiles status and change the status if necessary
    finderfilesstatus () {
    if [ "$STATUS" = "$SAF_OPT" ]
    then
    echo "AppleShowAllFiles is set to $SAF_OPT"
    else
    defaults write com.apple.finder AppleShowAllFiles $SAF_OPT
    osascript -e 'tell application "Finder" to quit' -e 'delay 1' -e 'tell application "Finder" to launch'
    fi
    }

    # Parse the command option
    case "$1" in
    '-h'|'--help') usage; exit;;
    'on'|'ON') SAF_OPT="ON"; finderfilesstatus;;
    'off'|'OFF') SAF_OPT="OFF"; finderfilesstatus;;
    *) echo "${0##*/} -h to access help"; exit;;
    esac
  • BobHarris Level 6 Level 6 (15,385 points)
    Which in this case the OP would need to run from somewhere,
    but since they cannot use the Terminal, they need another way of doing this.

    Your script could be used via Appliations -> Automator -> Run Shell script,
    replacing the default 'cat' command with your script.
  • Mark Jalbert Level 5 Level 5 (4,595 points)
    Or you could run it through the AppleSript Editor app. Though I'd would modify the script using the absolute path to each command.
  • etresoft Level 7 Level 7 (26,600 points)
    In the future, when editing your dotfiles, always test it by opening a new window while you have one or more old terminal windows already open. Then, if you find that you have broken it, you can still fix it.
  • Mike M 3998 Level 1 Level 1 (0 points)
    Assuming you haven't changed too much else, you're probably using "bash" as your shell. In that case, you can do this:

    1. go to Terminal->Preferences and click the "Startup" tab

    2. change "Shells open with:" to "command (complete path)"

    3. change the command to "/bin/bash -v -x -l" (without the quotes)

    4. click the "Settings" tab, then back to the "Startup" tab to make sure your edits took, then close the preferences window.

    Now when you open a terminal, bash will print out everything it's trying to do before it does it. The last thing you see before "Process Completed" is probably the culprit. If you scroll up a bit, you should see a line that starts with a dot (".") that names the file with the problem command.