从命令行预览 magit-status

从命令行执行 emacsclient --eval '(magit-status)',预览结果。效果图:


更改 server-eval-and-print

Emacsclient 的 --eval 默认打印所执行语句的结果,这里改成打印当前 Buffer:

(define-advice server-eval-and-print (:around (&rest r) print-buffer)
  "Print the current buffer instead of the result of evaluation."
  (require 'seq)
  (seq-let (_ expr proc) r
    (with-local-quit (eval (car (read-from-string expr))))
    (when proc
      (require 'e2ansi)
      (server-reply-print
       (server-quote-arg
        (let ((e2ansi-background-mode 'dark))
          (e2ansi-string-to-ansi (buffer-string))))
       proc))))

其中用 e2ansi 把 Emacs 的色彩转换成终端的色彩。

3 个赞

用来扫一眼 Org Agenda 也不错: