6

I usually use Spacemacs in maximized window, thus the date and time presented in mode line is a must.

I understand that spacemacs uses powerline mode to mimic vim, the manuals of both spacemacs and powerline does not tell how to add new section to display additional info (in this case it is date and time).

I have attempted to comprehend the nyan cat code in color layer, but my elisp skill did not satisfy.

7

To get the time mode, just add (display-time-mode 1) to your ~/.spacemacs configuration.

To get date and time, do this instead

;;display time in powerline
  (spacemacs|define-mode-line-segment date-time-segment
    (shell-command-to-string "echo -n $(date +%k:%M--%m-%d)")
    )
  (add-to-list 'spacemacs-mode-line-right 'date-time-segment)

Source: https://www.reddit.com/r/emacs/comments/3lu414/how_to_add_date_and_time_into_spacemacs_powerline/

I customized mine with this...

  ;; display time in powerline
  (spacemacs|define-mode-line-segment date-time-segment
    (shell-command-to-string "echo -n \"⏰  $(date '+%a %d %b %I:%M%p')\""))
  (add-to-list 'spacemacs-mode-line-right 'date-time-segment)
  )

so now my powerline looks like this

my_power_line

  • As far as I can tell, this solution is out of date. See my answer for what worked for me. – Dave Parrish Feb 25 '18 at 17:56
2

What worked for me was the following.

(spaceline-define-segment datetime
  (shell-command-to-string "echo -n $(date '+%a %d %b %I:%M%p')"))
(spaceline-spacemacs-theme 'datetime)

I had to put that code in user-config section of .spacemacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.