Add OS name detection for BSD OSes, memory improvements for UNIX
Simpler function for UNIX systems, including macOS. Bump to 0.6
This commit is contained in:
parent
41222b5f89
commit
0a8a340260
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
;; 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.5.0
|
;; Version: 0.6.0
|
||||||
;; Package-Requires: ((emacs "25") (dash "2") (f "0.20") (s "1"))
|
;; Package-Requires: ((emacs "25") (dash "2") (f "0.20") (s "1"))
|
||||||
;; Homepage: https://labs.phundrak.com/phundrak/eshell-info-banner.el
|
;; Homepage: https://labs.phundrak.com/phundrak/eshell-info-banner.el
|
||||||
|
|
||||||
@ -409,10 +409,16 @@ For TEXT-PADDING and BAR-LENGTH, see the documentation of
|
|||||||
"\n"
|
"\n"
|
||||||
t)))
|
t)))
|
||||||
|
|
||||||
(defun eshell-info-banner--get-memory/bsd ()
|
(defun eshell-info-banner--get-memory/unix ()
|
||||||
"Get memory usage for *BSD."
|
"Get memory usage for UNIX systems.
|
||||||
(message "Memory usage not yet implemented for BSD")
|
Compatible with Darwin and FreeBSD at least."
|
||||||
nil)
|
(let* ((command-to-mem (lambda (command)
|
||||||
|
(string-to-number (s-trim (cadr (split-string (shell-command-to-string command) " " t)))))))
|
||||||
|
`(("RAM"
|
||||||
|
,(apply command-to-mem '("sysctl hw.physmem"))
|
||||||
|
,(apply command-to-mem '("sysctl hw.usermem"))))))
|
||||||
|
|
||||||
|
(defalias 'eshell-info-banner--get-memory/bsd #'eshell-info-banner--get-memory/unix)
|
||||||
|
|
||||||
(defun eshell-info-banner--get-memory/darwin ()
|
(defun eshell-info-banner--get-memory/darwin ()
|
||||||
"Get memory usage for macOS."
|
"Get memory usage for macOS."
|
||||||
@ -460,8 +466,8 @@ in bytes."
|
|||||||
(eshell-info-banner--get-memory/gnu))
|
(eshell-info-banner--get-memory/gnu))
|
||||||
('gnu/kfreebsd
|
('gnu/kfreebsd
|
||||||
(eshell-info-banner--get-memory/bsd))
|
(eshell-info-banner--get-memory/bsd))
|
||||||
('darwin
|
((or 'darwin 'berkeley-unix)
|
||||||
(eshell-info-banner--get-memory/darwin))
|
(eshell-info-banner--get-memory/unix))
|
||||||
((or 'ms-dos 'windows-nt 'cygwin)
|
((or 'ms-dos 'windows-nt 'cygwin)
|
||||||
(eshell-info-banner--get-memory/windows))
|
(eshell-info-banner--get-memory/windows))
|
||||||
(os (warn "Memory usage not yet implemented for %s" os)
|
(os (warn "Memory usage not yet implemented for %s" os)
|
||||||
@ -657,6 +663,11 @@ If RELEASE-FILE is nil, use '/etc/os-release'."
|
|||||||
(substring-no-properties distro
|
(substring-no-properties distro
|
||||||
(match-beginning 1)
|
(match-beginning 1)
|
||||||
(match-end 1))))))
|
(match-end 1))))))
|
||||||
|
((equal system-type 'gnu/kfreebsd)
|
||||||
|
(let* ((default-directory (if eshell-info-banner-tramp-aware default-directory "~")))
|
||||||
|
(s-trim (with-temp-buffer
|
||||||
|
(process-file "uname" nil t nil "-s")
|
||||||
|
(buffer-string)))))
|
||||||
(t "Unknown"))
|
(t "Unknown"))
|
||||||
.
|
.
|
||||||
,(s-trim (shell-command-to-string "uname -rs")))))
|
,(s-trim (shell-command-to-string "uname -rs")))))
|
||||||
@ -685,7 +696,7 @@ build number)."
|
|||||||
(pcase system-type
|
(pcase system-type
|
||||||
((or 'ms-dos 'windows-nt 'cygwin)
|
((or 'ms-dos 'windows-nt 'cygwin)
|
||||||
(eshell-info-banner--get-os-information/windows))
|
(eshell-info-banner--get-os-information/windows))
|
||||||
((or 'gnu 'gnu/linux 'gnu/kfreebsd)
|
((or 'gnu 'gnu/linux 'gnu/kfreebsd 'berkeley-unix)
|
||||||
(eshell-info-banner--get-os-information/gnu))
|
(eshell-info-banner--get-os-information/gnu))
|
||||||
('darwin
|
('darwin
|
||||||
(eshell-info-banner--get-os-information/darwin))
|
(eshell-info-banner--get-os-information/darwin))
|
||||||
|
Loading…
Reference in New Issue
Block a user