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 when it completed. I want to start console work with preconfigured variables. How can I make it does not exit after script execution complete?
Asked
Active
Viewed 7,729 times
3
-
Could you show your script? The obvious ways I tried leave the terminal running. – geekosaur Mar 23 '11 at 05:00
-
2@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 06:09
-
@DanielBeck Yes, the question is whether there is a way to counter it? – Dr_Zaszuś Apr 21 '20 at 20:17
1 Answers
4
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.
Drooling_Sheep
- 428
- 3
- 9
-
1Oh I'm sorry for my question was unclear. I was wanted to start console work at the point. – Eonil Mar 23 '11 at 05:39
-
-
it works, but it launches a new shell instead of remaining opened shell. Preconfigured environment variables are disappeared. – Eonil Mar 23 '11 at 06: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 06:18