Elisp: Run Elisp Script in Terminal

By Xah Lee. Date: . Last updated: .

Run Emacs Lisp Script in Shell

to run emacs lisp script in shell (terminal), use the --script option.

emacs --script myfile.el
;; -*- coding: utf-8; lexical-binding: t; -*-

;; save this file as myfile.el
;; run it in terminal, like this
;; emacs --script myfile.el

(message "Hi. Today is %s"
         (format-time-string "%Y-%m-%d"))

Prepare Emacs Lisp Script to Run in Batch Mode

make sure your elisp file is:

Run Elisp Script in Terminal