假设了当emacs打开的时候,emacs-server也同样打开
(defun colawithsauce/org-agenda-get-todos ()
"Get todo and scheduled items until today."
(let ((matched-items '())
(print-result ""))
(dolist (match
(org-map-entries 'org-heading-components "SCHEDULED<=\"<today>\"/-DONE" 'agenda))
(when (member (nth 2 match) '("[!]" "TODO" "[?]" "HACKING"))
(push (concat "■ " (nth 4 match)) matched-items)))
(while matched-items
(setq print-result (concat (car matched-items) "\n" print-result))
(setq matched-items (cdr matched-items)))
(message print-result)))
然后再在 ~/.zshrc 最前面加一句
if [ "$(pgrep emacs)" ]
then
echo "今天要做的任务:"
echo "$(emacsclient --eval '(colawithsauce/org-agenda-get-todos)'|tr -d \")"
fi
效果如下: