I am trying to write a script which will two tabs on a terminal. I want each tab to tail a different logfile. The script is located in a /scripts directory and the logs are located in the parent directory.
The first tab and tail works fine. The second does not because it opens it in my home directory.
Here is the script:
CURRENT_DIR=$(pwd);
# First tail
osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' -e 'tell application "Terminal" to do script "cd ..;tail -f my.log" in selected tab of the front window';
# Second tail
cd $CURRENT_DIR;
osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' -e 'tell application "Terminal" to do script "cd ..;tail -f mySecond.log" in selected tab of the front window';
The second tail never works because it opens the tab in my home directory for some odd reason.
Usually when I do cmd + t
the new terminal tab opens in the same directory.
Any ideas on what I am doing wrong?