Ethan Lee
Ethan Lee

Reputation: 178

Run emacs in Terminal using AppleScript

I wish to create an AppleScript application in Xcode that launches Terminal and runs emacs. I would also like it to type Esc-X after it finishes and follow that with whatever emacs program I need to run. I've tried do shell script "emacs" but the log output is

[XXAppDelegate applicationWillFinishLaunching:]: emacs: standard input is not a tty (error 1)

and that still does not solve the issue of typing in Esc-X later.

Being new to AppleScript, I don't know much beyond basic commands, so any help is greatly appreciated.

Upvotes: 1

Views: 397

Answers (1)

Ethan Lee
Ethan Lee

Reputation: 178

Just found this to work:

tell application "Terminal"
     set currentTab to do script "emacs"
end tell

tell application "Terminal" to activate
tell application "System Events" to key code 53

This makes the current tab (or new tab) of Terminal run emacs and type Esc.

Upvotes: 3

Related Questions