10 Commits
0.7.2 ... 0.7.6

2 changed files with 55 additions and 40 deletions

View File

@@ -1,6 +1,9 @@
#+title: eshell-info-banner.el #+title: eshell-info-banner.el
#+author: Lucien Cartier-Tilet #+author: Lucien Cartier-Tilet
#+email: lucien@phundrak.com #+email: lucien@phundrak.com
[[https://melpa.org/#/eshell-info-banner][file:https://melpa.org/packages/eshell-info-banner-badge.svg]]
[[https://stable.melpa.org/#/eshell-info-banner][file:https://stable.melpa.org/packages/eshell-info-banner-badge.svg]]
* Introduction * Introduction
~eshell-info-banner.el~ is a utility for creating an informative banner, ~eshell-info-banner.el~ is a utility for creating an informative banner,
akin to ~fish_greeting~ but for Eshell. But an image is worth a thousand akin to ~fish_greeting~ but for Eshell. But an image is worth a thousand
@@ -60,12 +63,12 @@ your ~load-path~ and add the following to your ~.emacs~ or your ~init.el~:
(add-hook 'eshell-banner-load-hook 'eshell-info-banner-update-banner) (add-hook 'eshell-banner-load-hook 'eshell-info-banner-update-banner)
#+end_src #+end_src
If you use ~use-package~ only, you can then install it like so: If you use ~use-package~ only and install the package from MELPA, you
can then install it like so:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package eshell-info-banner (use-package eshell-info-banner
:ensure t :ensure t
:defer t :defer t
:load-path "~/path/to/where/you/cloned/it/eshell-info-banner.el/"
:hook (eshell-banner-load . eshell-info-banner-update-banner)) :hook (eshell-banner-load . eshell-info-banner-update-banner))
#+end_src #+end_src
@@ -74,23 +77,17 @@ In my case, I prefer using ~use-package~ with ~straight~:
(use-package eshell-info-banner (use-package eshell-info-banner
:ensure t :ensure t
:defer t :defer t
:straight (eshell-info-banner :type git :straight (:build t)
:host github
:repo "phundrak/eshell-info-banner.el")
:hook (eshell-banner-load . eshell-info-banner-update-banner)) :hook (eshell-banner-load . eshell-info-banner-update-banner))
#+end_src #+end_src
I personally also added ~:build t~ in the straight recipe to ensure You can just use ~:straight t~ if you do not want to ensure the package
Emacs compiles my package, both to ~.elc~ and ~.eln~ files (I am on Emacs gets compiled by Emacs.
28.0, ~feature/native-comp~ got merged into ~master~!)
There is probably a similar way to install it with pure ~straight.el~ or There is probably a similar way to install it with pure ~straight.el~ or
~quelpa~, but Im not knowledgable enough for that, feel free to create ~quelpa~, but Im not knowledgable enough for that, feel free to create
a PR to add some more installation instructions! a PR to add some more installation instructions!
There is currently no plans of making this package available on MELPA
or non-gnu elpa.
* Customizing * Customizing
A couple of variables can be edited by the user in order to configure A couple of variables can be edited by the user in order to configure
~eshell-info-banner.el~: ~eshell-info-banner.el~:
@@ -181,4 +178,4 @@ See [[file:CONTRIBUTING.org]].
* License * License
~eshell-info-banner.el~ is available under the GNU GPL-3.0 license. You ~eshell-info-banner.el~ is available under the GNU GPL-3.0 license. You
can find the full text in [[file:LICENSE.md][LICENSE.md]]. can find the full text in the [[file:LICENSE][LICENSE]] file.

View File

@@ -2,9 +2,9 @@
;; Author: Lucien Cartier-Tilet <lucien@phundrak.com> ;; Author: Lucien Cartier-Tilet <lucien@phundrak.com>
;; Maintainer: Lucien Cartier-Tilet <lucien@phundrak.com> ;; Maintainer: Lucien Cartier-Tilet <lucien@phundrak.com>
;; Version: 0.7.1 ;; Version: 0.7.6
;; Package-Requires: ((emacs "25.1") (f "0.20") (s "1")) ;; Package-Requires: ((emacs "25.1") (f "0.20") (s "1"))
;; Homepage: https://labs.phundrak.com/phundrak/eshell-info-banner.el ;; Homepage: https://github.com/Phundrak/eshell-info-banner.el
;; This file is not part of GNU Emacs ;; This file is not part of GNU Emacs
@@ -82,7 +82,9 @@
("11.1" . "macOS Big Sur") ("11.1" . "macOS Big Sur")
("11.2" . "macOS Big Sur") ("11.2" . "macOS Big Sur")
("11.3" . "macOS Big Sur") ("11.3" . "macOS Big Sur")
("11.4" . "macOS Big Sur")) ("11.4" . "macOS Big Sur")
("11.5" . "macOS Big Sur")
("11.6" . "macOS Big Sur"))
"Versions of OSX and macOS and their name.")) "Versions of OSX and macOS and their name."))
@@ -301,17 +303,18 @@ Common function between
otherwise differ solely on the position of the mount point in the otherwise differ solely on the position of the mount point in the
partition list. Its position is given by the argument partition list. Its position is given by the argument
MOUNT-POSITION." MOUNT-POSITION."
(let ((partitions (split-string (eshell-info-banner--shell-command-to-string "df -lH") (let ((partitions (cdr (split-string (eshell-info-banner--shell-command-to-string "df -lH")
(regexp-quote "\n") (regexp-quote "\n")
t))) t))))
(seq-filter (lambda (partition) (cl-remove-if #'null
(mapcar (lambda (partition)
(let* ((partition (split-string partition " " t)) (let* ((partition (split-string partition " " t))
(filesystem (nth 0 partition)) (filesystem (nth 0 partition))
(size (nth 1 partition)) (size (nth 1 partition))
(used (nth 2 partition)) (used (nth 2 partition))
(percent (nth 4 partition)) (percent (nth 4 partition))
(mount (nth mount-position partition))) (mount (nth mount-position partition)))
(unless (seq-some (lambda (prefix) (when (seq-some (lambda (prefix)
(string-prefix-p prefix filesystem t)) (string-prefix-p prefix filesystem t))
eshell-info-banner-partition-prefixes) eshell-info-banner-partition-prefixes)
(make-eshell-info-banner--mounted-partitions (make-eshell-info-banner--mounted-partitions
@@ -322,7 +325,7 @@ MOUNT-POSITION."
:used used :used used
:percent (string-to-number :percent (string-to-number
(string-trim-left percent (regexp-quote "%"))))))) (string-trim-left percent (regexp-quote "%")))))))
partitions))) partitions))))
(defun eshell-info-banner--get-mounted-partitions-gnu () (defun eshell-info-banner--get-mounted-partitions-gnu ()
"Detect mounted partitions on a Linux system. "Detect mounted partitions on a Linux system.
@@ -402,7 +405,7 @@ For TEXT-PADDING and BAR-LENGTH, see the documentation of
; Memory ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Memory ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun eshell-info-banner--get-memory-gnu () (defun eshell-info-banner--get-memory-gnu ()
"Get memory usage for GNU/Linux and Hurd." "Get memory usage for GNU/Linux and Hurd."
(seq-do (lambda (line) (mapcar (lambda (line)
(let* ((line (split-string line " " t))) (let* ((line (split-string line " " t)))
(list (s-chop-suffix ":" (nth 0 line)) ; name (list (s-chop-suffix ":" (nth 0 line)) ; name
(string-to-number (nth 1 line)) ; total (string-to-number (nth 1 line)) ; total
@@ -549,8 +552,9 @@ The usage of `eshell-info-banner-warning-percentage' and
thought of as the “percentage of discharge” of the computer. thought of as the “percentage of discharge” of the computer.
Thus, setting the warning at 75% will be translated as showing Thus, setting the warning at 75% will be translated as showing
the warning face with a battery level of 25% or less." the warning face with a battery level of 25% or less."
(let ((battery-level (battery))) (let ((battery-level (when (file-readable-p "/sys/") (battery))))
(if (or (string= battery-level "Battery status not available") (if (or (null battery-level)
(string= battery-level "Battery status not available")
(string-match-p (regexp-quote "N/A") battery-level)) (string-match-p (regexp-quote "N/A") battery-level))
"" ""
(let ((percentage (save-match-data (let ((percentage (save-match-data
@@ -624,6 +628,20 @@ If RELEASE-FILE is nil, use '/etc/os-release'."
"See `eshell-info-banner--get-os-information'." "See `eshell-info-banner--get-os-information'."
(let ((prefix (if eshell-info-banner-tramp-aware (file-remote-p default-directory) ""))) (let ((prefix (if eshell-info-banner-tramp-aware (file-remote-p default-directory) "")))
`(,(cond `(,(cond
;; Bedrock Linux
((file-exists-p (concat prefix "/bedrock/etc/bedrock-release"))
(s-trim (with-temp-buffer
(insert-file-contents (concat prefix "/bedrock/etc/bedrock-release"))
(buffer-string))))
;; Proxmox
((executable-find "pveversion" eshell-info-banner-tramp-aware)
(let ((distro (eshell-info-banner--shell-command-to-string "pveversion")))
(save-match-data
(string-match "/\\([^/]+\\)/" distro)
(concat "Proxmox "
(substring-no-properties distro
(match-beginning 1)
(match-end 1))))))
((executable-find "hostnamectl" eshell-info-banner-tramp-aware) ((executable-find "hostnamectl" eshell-info-banner-tramp-aware)
(eshell-info-banner--get-os-information-from-hostnamectl)) (eshell-info-banner--get-os-information-from-hostnamectl))
((executable-find "lsb_release" eshell-info-banner-tramp-aware) ((executable-find "lsb_release" eshell-info-banner-tramp-aware)