Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm making a shortcut icon on my Dock which opens a terminal window with some preconfigured environment variables. I made a script and dragged it into my Dock. It runs well, however it exits immediately as it complete. I want to start console work with preconfigured variables. How can I make it does not exit after script execution complete?

share|improve this question
    
Could you show your script? The obvious ways I tried leave the terminal running. – geekosaur Mar 23 '11 at 5:00
    
@geekosaur The user probably uses an executable .command or .tool file. Opening such a file translates to a Terminal command of the form /path/to/filename.command ; exit;. – Daniel Beck Mar 23 '11 at 6:09
up vote 2 down vote accepted

You can put

read -p "Press Return to Close..."

as the last line of the script. That will keep it up until you hit enter.

Re: your edit

If you invoke bash (or whatever shell you use) as the last line of the script it should (as in does for me on Linux) stay open with a prompt.

share|improve this answer
    
Oh I'm sorry for my question was unclear. I was wanted to start console work at the point. – Eonil Mar 23 '11 at 5:39
    
@Eonil, I edited my answer. Does this work for you? – Drooling_Sheep Mar 23 '11 at 5:49
    
it works, but it launches a new shell instead of remaining opened shell. Preconfigured environment variables are disappeared. – Eonil Mar 23 '11 at 6:09
    
@Eonil I tested it using export FOO="Hello World"; bash as script, then typed echo $FOO and it showed up. Alternatively, create a bash-script ad-hoc in your script and use it as bash --init-file to define your environment. – Daniel Beck Mar 23 '11 at 6:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .