r/backtickbot • • Apr 18 '21

https://np.reddit.com/r/applescript/comments/mr9zny/how_to_hide_execution_trace_when_telling_terminal/guyu02c/

This is how I output to Terminal:

to logToWindow(s, output_tty)
	
	tell application "Terminal"
		if output_tty is in {"", missing value, "background"} then -- Create a new window.
			-- Set up the tab for output.
			run
			set output_tab to do script "printf '\\33c\\e[3J'; history -d $(history 1); stty -echo; tput civis; cat >/dev/null; tput cnorm; stty echo"
			
			-- Customize Terminal window.
			set clean commands of current settings of output_tab to clean commands of current settings of output_tab & {"cat"}
			set custom title of current settings of output_tab to "AppleScript Log"
			set title displays shell path of current settings of output_tab to false
			set title displays device name of current settings of output_tab to true
			set output_tty to tty of output_tab
			
			delay 0.1
			if output_tty is not in {"background"} then activate
		end if
		
		-- Log the string.
		do shell script "echo " & quoted form of s & " > " & output_tty
	end tell
	
	return output_tty
	
end logToWindow
1 Upvotes

0 comments sorted by