Insert Text at Cursor on macOS Requirement: Enable Accessibility for the Terminal application. tell application "System Events" keystroke "text to be inserted\n" end tell
Also supported:
keystroke tab
: Press the tab key.keystroke return
: Press the return key.