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?

link|improve this question

68% accept rate
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
feedback

1 Answer

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.

link|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
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.