;;; init-dashboard.el -*- lexical-binding: t -*- (use-package dashboard :diminish dashboard-mode :functions (nerd-icons-faicon nerd-icons-mdicon winner-undo widget-forward) :custom-face (dashboard-heading ((t (:inherit (font-lock-string-face bold))))) (dashboard-items-face ((t (:weight normal)))) (dashboard-no-items-face ((t (:weight normal)))) :pretty-hydra ((:title (pretty-hydra-title "Dashboard" 'mdicon "nf-md-view_dashboard") :color pink :quit-key ("q" "C-g")) ("Navigator" (("U" update-config-and-packages "update" :exit t) ("H" browse-homepage "homepage" :exit t) ("R" restore-previous-session "recover session" :exit t) ("L" restore-session "list sessions" :exit t) ("S" find-custom-file "settings" :exit t)) "Section" (("}" dashboard-next-section "next") ("{" dashboard-previous-section "previous") ("r" dashboard-goto-recent-files "recent files") ("m" dashboard-goto-bookmarks "bookmarks") ("p" dashboard-goto-projects "projects")) "Item" (("RET" widget-button-press "open" :exit t) ("" widget-forward "next") ("C-i" widget-forward "next") ("" widget-backward "previous") ("C-n" next-line "next line") ("C-p" previous-line "previous line")) "Misc" (("" open-dashboard "open" :exit t) ("g" dashboard-refresh-buffer "refresh" :exit t) ("Q" quit-dashboard "quit" :exit t)))) :bind (("" . open-dashboard) :map dashboard-mode-map ("H" . browse-homepage) ("R" . restore-previous-session) ("L" . restore-session) ("S" . find-custom-file) ("U" . update-config-and-packages) ("q" . quit-dashboard) ("h" . dashboard-hydra/body) ("?" . dashboard-hydra/body)) :hook (dashboard-mode . (lambda () ;; No title (setq-local frame-title-format nil) ;; Enable `page-break-lines-mode' (when (fboundp 'page-break-lines-mode) (page-break-lines-mode 1)))) :init (setq dashboard-banner-logo-title "CENTAUR EMACS - Enjoy Programming & Writing" ;;dashboard-startup-banner (or centaur-logo 'official) dashboard-page-separator "\n\f\n" dashboard-projects-backend 'project-el dashboard-path-style 'truncate-middle dashboard-path-max-length 60 dashboard-center-content t dashboard-show-shortcuts nil dashboard-items '((recents . 10) (bookmarks . 5) (projects . 5)) dashboard-set-init-info t dashboard-display-icons-p #'icons-displayable-p dashboard-icon-type 'nerd-icons dashboard-set-file-icons t dashboard-set-heading-icons t dashboard-heading-icons '((recents . "nf-oct-history") (bookmarks . "nf-oct-bookmark") (agenda . "nf-oct-calendar") (projects . "nf-oct-briefcase") (registers . "nf-oct-database")) dashboard-set-footer t dashboard-footer-icon (cond ((icons-displayable-p) (nerd-icons-octicon "nf-oct-heart" :height 1.2 :face 'nerd-icons-lred)) (t (propertize ">" 'face 'dashboard-footer))) dashboard-set-navigator t dashboard-navigator-buttons `(((,(when (icons-displayable-p) (nerd-icons-mdicon "nf-md-github" :height 1.5)) "Homepage" "Browse homepage" (lambda (&rest _) (browse-url centaur-homepage))) (,(when (icons-displayable-p) (nerd-icons-mdicon "nf-md-backup_restore" :height 1.5)) "Restore" "Restore previous session" (lambda (&rest _) (restore-previous-session))) (,(when (icons-displayable-p) (nerd-icons-mdicon "nf-md-tools" :height 1.5)) "Settings" "Open custom file" (lambda (&rest _) (find-file custom-file))) (,(when (icons-displayable-p) (nerd-icons-mdicon "nf-md-update" :height 1.5)) "Update" "Update Centaur Emacs" (lambda (&rest _) (centaur-update))) (,(if (icons-displayable-p) (nerd-icons-mdicon "nf-md-help" :height 1.5) "?") "" "Help (?/h)" (lambda (&rest _) (dashboard-hydra/body)) font-lock-string-face)))) (dashboard-setup-startup-hook) :config ;; Insert copyright ;; @see https://github.com/emacs-dashboard/emacs-dashboard/issues/219 (defun restore-previous-session () "Restore the previous session." (interactive) (when (bound-and-true-p persp-mode) (restore-session persp-auto-save-fname))) (defun restore-session (fname) "Restore the specified session." (interactive (list (read-file-name "Load perspectives from a file: " persp-save-dir))) (when (bound-and-true-p persp-mode) (message "Restoring session...") (quit-window t) (condition-case-unless-debug err (persp-load-state-from-file fname) (error "Error: Unable to restore session -- %s" err)) (message "Restoring session...done"))) (defun dashboard-goto-recent-files () "Go to recent files." (interactive) (let ((func (local-key-binding "r"))) (and func (funcall func)))) (defun dashboard-goto-projects () "Go to projects." (interactive) (let ((func (local-key-binding "p"))) (and func (funcall func)))) (defun dashboard-goto-bookmarks () "Go to bookmarks." (interactive) (let ((func (local-key-binding "m"))) (and func (funcall func)))) (defvar dashboard-recover-layout-p nil "Wether recovers the layout.") (defun open-dashboard () "Open the *dashboard* buffer and jump to the first widget." (interactive) ;; Check if need to recover layout (if (length> (window-list-1) ;; exclude `treemacs' window (if (and (fboundp 'treemacs-current-visibility) (eq (treemacs-current-visibility) 'visible)) 2 1)) (setq dashboard-recover-layout-p t)) ;; Display dashboard in maximized window (delete-other-windows) ;; Refresh dashboard buffer (dashboard-refresh-buffer) ;; Jump to the first section (dashboard-goto-recent-files)) (defun quit-dashboard () "Quit dashboard window." (interactive) (quit-window t) (and dashboard-recover-layout-p (and (bound-and-true-p winner-mode) (winner-undo)) (setq dashboard-recover-layout-p nil)))) ;;(use-package dashboard ;; :diminish dashboard-mode ;; :hook (dashboard-mode . (lambda () ;; ;; No title ;; (setq-local frame-title-format nil) ;; ;; Enable `page-break-lines-mode' ;; (when (fboundp 'page-break-lines-mode) ;; (page-break-lines-mode 1)))) ;; :config ;; (setq dashboard-set-heading-icons t) ;; (setq dashboard-set-file-icons t) ;; (setq dashboard-icon-type 'nerd-icons) ;; ;; ;;(setq dashboard-banner-logo-title "Emacs is more than a text editor!") ;; ;; logo from github.com/egstatsml/emacs_fancy_logos ;; ;;(setq dashboard-startup-banner "~/.config/emacs/logos/xemacs_color.png") ;; ;;(setq dashboard-startup-banner 'logo) ;; (setq dashboard-center-content t) ;; (setq dashboard-week-agenda t) ;; (setq dashboard-set-footer t) ;; ;;(setq dashboard-page-separator "\n\n") ;; (setq dashboard-page-separator "\n\f\n") ;; (setq dashboard-agenda-time-string-format "%d/%m/%Y %A %H:%M") ;; (setq dashboard-projects-backend 'project-el) ;; (setq dashboard-items '((recents . 10) ;; (agenda . 5) ;; (bookmarks . 5) ;; ;;(if (version< emacs-version "29") ;; ;;(projects . 5) ;; (registers . 5))) ;; (setq dashboard-set-navigator t) ;; ;; ;;(setq dashboard-navigator-buttons ;; ;; `(;; line1 ;; ;; ((,(all-the-icons-octicon "mark-github" :height 1.1 :v-adjust 0.0) ;; ;; "Github" ;; ;; "Browse my Github" ;; ;; (lambda (&rest _) (browse-url "https://github.com/JaeUs3792/"))) ;; ;; (,(all-the-icons-octicon "home" :height 1.1 :v-adjust 0.0) ;; ;; "Homepage" ;; ;; "Browse my Homepage" ;; ;; (lambda (&rest _) (browse-url "https://jaeus.net"))) ;; ;; (,(all-the-icons-octicon "zap" :height 1.1 :v-adjust 0.0) ;; ;; "Refresh" ;; ;; "Refresh Packages" ;; ;; (lambda (&rest _) (package-refresh-contents)) warning)))) ;; ;; (dashboard-setup-startup-hook) ;; (dashboard-modify-heading-icons '((recents . "file-text") ;; (bookmarks . "book"))) ;; (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")))) (provide 'init-dashboard) ;;; init-dashboard.el ends here