0

I'm executing a bash command from AppleScript but the script is quite ugly and I am only interested to see the output in a terminal.

Example:

tell application "Terminal" do script "pwd" end tell 

Terminal(I want to hide pwd):

pwd /Users/jdoe 

2 Answers 2

2

If you use clear (or tput clear or printf \\ec), the old contents are shown if you scroll up:

tell application "Terminal" do script " clear; pwd" activate end tell 

This can have a noticeable delay if System Events is not running:

tell application "Terminal" do script " osascript -e 'tell app \"system events\" to keystroke \"k\" using command down'; pwd" activate end tell 
Sign up to request clarification or add additional context in comments.

Comments

1

The command is do shell script "pwd", and it did show only the output when I ran it in Script Editor or via osascript test.scpt in a Terminal.

3 Comments

I've updated my example, instead of "pwd" there is an interactive script and "do script" executes it through the terminal.
Why do you go to the trouble of starting a Terminal instead of simply running do shell script?
Because I want a user to interact with it in a terminal, do shell script would execute it in the background.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.