Rename function, and set locale for `vm_stat'

This commit is contained in:
Lucien Cartier-Tilet 2021-05-23 00:05:37 +02:00
parent 46ada1b264
commit 913120fae5
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -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.4.3 ;; Version: 0.4.4
;; Package-Requires: ((emacs "24") (dash "2") (f "0.20") (s "1")) ;; Package-Requires: ((emacs "24") (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
@ -174,7 +174,7 @@ If the executable `uptime' is not found, return nil."
(string-match-p keyword uptime-str)) (string-match-p keyword uptime-str))
'("invalid" "illegal"))) '("invalid" "illegal")))
(s-chop-prefix "up " (s-trim uptime-str)) (s-chop-prefix "up " (s-trim uptime-str))
(let ((uptime-str (shell-command-to-string "uptime"))) (let ((uptime-str (shell-command-to-string "LANG=C uptime")))
(save-match-data (save-match-data
(string-match "[^,]+up *\\([^,]+\\)," uptime-str) (string-match "[^,]+up *\\([^,]+\\)," uptime-str)
(s-trim (substring-no-properties uptime-str (s-trim (substring-no-properties uptime-str
@ -342,7 +342,7 @@ For TEXT-PADDING and BAR-LENGTH, see the documentation of
; Memory ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Memory ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun eshell-info-banner--get-memory/linux () (defun eshell-info-banner--get-memory/gnu ()
"Get memory usage for GNU/Linux and Hurd." "Get memory usage for GNU/Linux and Hurd."
(-map (lambda (line) (-map (lambda (line)
(let* ((line (split-string line " " t))) (let* ((line (split-string line " " t)))
@ -360,7 +360,7 @@ For TEXT-PADDING and BAR-LENGTH, see the documentation of
(defun eshell-info-banner--get-memory/darwin () (defun eshell-info-banner--get-memory/darwin ()
"Get memory usage for macOS." "Get memory usage for macOS."
(let* ((mem (s-lines (shell-command-to-string "vm_stat"))) (let* ((mem (s-lines (shell-command-to-string "LANG=C vm_stat")))
(mem (cl-remove-if-not (lambda (line) (mem (cl-remove-if-not (lambda (line)
(string-match-p "^Pages \\(free\\|active\\|inactive\\|speculative\\|wired\\)" (string-match-p "^Pages \\(free\\|active\\|inactive\\|speculative\\|wired\\)"
line)) line))
@ -401,7 +401,7 @@ total amount of memory available, and the amount of used memory,
in bytes." in bytes."
(pcase system-type (pcase system-type
((or 'gnu 'gnu/linux) ((or 'gnu 'gnu/linux)
(eshell-info-banner--get-memory/linux)) (eshell-info-banner--get-memory/gnu))
('gnu/kfreebsd ('gnu/kfreebsd
(eshell-info-banner--get-memory/bsd)) (eshell-info-banner--get-memory/bsd))
('darwin ('darwin