buc99
Don't Tread on Me!
I have a script that asks for a file name and then opens a specific directory and inside the terminal. It then opens vi within the terminal with that filename:
display dialog ¬
"Please enter name of project file:" default answer "samp.c" buttons {"Ok", "Cancel"} ¬
default button "Ok"
if button returned of result = "Ok" then
set z to text returned of result
else
exit repeat
end if
tell application "Terminal"
do script "pushd Sandbox/Programming/Code_src/C"
do script "vi " & z
end tell
The problem here is that (#1, I'm not a very prolific Applescript programmer. But besides that ...) if the terminal is not open this script will open a terminal window, open another terminal window and launch the command "pushd Sandbox/Programming/Code_src/C", and then open another window and execute the command '"vi " & z'. I would like the applescript to just open one terminal window and then launch the two unix commands inside that one single window so that I have only one terminal window open when it is all said and done. One way to get the two commands to execute sequentially in one window is to change the 'do script' lines to:
do script "pushd Sandbox/Programming/Code_src/C; vi " & z
This is basically a Unix fix and I still have two terminal windows open if the Terminal.app is not already active. So how do I accomplish my gaol in a more 'Applescript' kind of way?
Thanks in advance.
SA
display dialog ¬
"Please enter name of project file:" default answer "samp.c" buttons {"Ok", "Cancel"} ¬
default button "Ok"
if button returned of result = "Ok" then
set z to text returned of result
else
exit repeat
end if
tell application "Terminal"
do script "pushd Sandbox/Programming/Code_src/C"
do script "vi " & z
end tell
The problem here is that (#1, I'm not a very prolific Applescript programmer. But besides that ...) if the terminal is not open this script will open a terminal window, open another terminal window and launch the command "pushd Sandbox/Programming/Code_src/C", and then open another window and execute the command '"vi " & z'. I would like the applescript to just open one terminal window and then launch the two unix commands inside that one single window so that I have only one terminal window open when it is all said and done. One way to get the two commands to execute sequentially in one window is to change the 'do script' lines to:
do script "pushd Sandbox/Programming/Code_src/C; vi " & z
This is basically a Unix fix and I still have two terminal windows open if the Terminal.app is not already active. So how do I accomplish my gaol in a more 'Applescript' kind of way?
Thanks in advance.
SA