1

On my Mac OSX 10.9 Mavericks, I wrote a small bash script to open a log file for a terminal game application I'm writing so I can see print statements:

#!/bin/bash

printf '\e[3;0;0t'                                  # move
printf '\e[8;35;61'                                 # resize
tail -f ~/Library/Logs/Aaron/logfile--[default].txt # open log file

And I open it from another script like this (which contains other various calls to setup my dev environment not shown here):

#!/bin/bash

printf '\e[3;681;0t'                     # move
printf '\e[8;35;61t'                     # resize
open -a Terminal.app scripts/view_log.sh # open log file in new window
printf '\e[5t'                           # request focus

It all works great except that when I cancel execution of tail, it auto exits the terminal. I notice at the top of the terminal it has the following prompt:

/Users/aaron/code/c/game2/scripts/view_log.sh ; exit;

How can I prevent the terminal from prepending this exit command? Is there a way to launch a new Terminal and keep it around to use for other commands afterwards?

(Someone here suggested adding the line $SHELL at the end of the script, but that was for Ubuntu's gnome-terminal)

0

One simplistic way is spawning a new shell at the end of your script. Just put the command

bash

as the last line in your view_log.sh script.

It's not pretty, as you normally don't want to open another subshell, but it keeps the original window open.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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