Simplify code retrieving partitions between GNU and Darwin systems
Also bump revision number
This commit is contained in:
parent
b2eff90711
commit
48470a4b85
@ -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.6.0
|
;; Version: 0.6.1
|
||||||
;; 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
|
||||||
|
|
||||||
@ -289,20 +289,22 @@ chosen. Relies on the `duf' command."
|
|||||||
:percent percent)))
|
:percent percent)))
|
||||||
partitions)))
|
partitions)))
|
||||||
|
|
||||||
(defun eshell-info-banner--get-mounted-partitions/gnu ()
|
(defun eshell-info-banner--get-mounted-partitions/df (mount-position)
|
||||||
"Detect mounted partitions on a Linux system.
|
"Get mounted partitions through df.
|
||||||
|
Common function between
|
||||||
Return detected partitions as a list of structs. See
|
`eshell-info-banner--get-mounted-partitions/gnu' and
|
||||||
`eshell-info-banner-partition-prefixes' to see how partitions are
|
`eshell-info-banner--get-mounted-partitions/darwing' which would
|
||||||
chosen. Relies on the `df' command."
|
otherwise differ solely on the position of the mount point in the
|
||||||
|
partition list. Its position is given by the argument
|
||||||
|
MOUNT-POSITION."
|
||||||
(let ((partitions (split-string (eshell-info-banner--shell-command-to-string "df -lH") (regexp-quote "\n") t)))
|
(let ((partitions (split-string (eshell-info-banner--shell-command-to-string "df -lH") (regexp-quote "\n") t)))
|
||||||
(-keep (lambda (partition)
|
(-keep (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 5 partition)))
|
(mount (nth mount-position partition)))
|
||||||
(when (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)
|
||||||
@ -316,6 +318,14 @@ chosen. Relies on the `df' command."
|
|||||||
(string-trim-left percent (regexp-quote "%")))))))
|
(string-trim-left percent (regexp-quote "%")))))))
|
||||||
partitions)))
|
partitions)))
|
||||||
|
|
||||||
|
(defun eshell-info-banner--get-mounted-partitions/gnu ()
|
||||||
|
"Detect mounted partitions on a Linux system.
|
||||||
|
|
||||||
|
Return detected partitions as a list of structs. See
|
||||||
|
`eshell-info-banner-partition-prefixes' to see how partitions are
|
||||||
|
chosen. Relies on the `df' command."
|
||||||
|
(eshell-info-banner--get-mounted-partitions/df 5))
|
||||||
|
|
||||||
(defun eshell-info-banner--get-mounted-partitions/windows ()
|
(defun eshell-info-banner--get-mounted-partitions/windows ()
|
||||||
"Detect mounted partitions on a Windows system.
|
"Detect mounted partitions on a Windows system.
|
||||||
|
|
||||||
@ -332,26 +342,7 @@ chosen."
|
|||||||
Return detected partitions as a list of structs. See
|
Return detected partitions as a list of structs. See
|
||||||
`eshell-info-banner-partition-prefixes' to see how partitions are
|
`eshell-info-banner-partition-prefixes' to see how partitions are
|
||||||
chosen. Relies on the `df' command."
|
chosen. Relies on the `df' command."
|
||||||
(let ((partitions (split-string (eshell-info-banner--shell-command-to-string "df -lH") (regexp-quote "\n") t)))
|
(eshell-info-banner--get-mounted-partitions/df 8))
|
||||||
(-keep (lambda (partition)
|
|
||||||
(let* ((partition (split-string partition " " t))
|
|
||||||
(filesystem (nth 0 partition))
|
|
||||||
(size (nth 1 partition))
|
|
||||||
(used (nth 2 partition))
|
|
||||||
(percent (nth 4 partition))
|
|
||||||
(mount (nth 8 partition)))
|
|
||||||
(when (seq-some (lambda (prefix)
|
|
||||||
(string-prefix-p prefix filesystem t))
|
|
||||||
eshell-info-banner-partition-prefixes)
|
|
||||||
(make-eshell-info-banner--mounted-partitions
|
|
||||||
:path (if (> (length mount) eshell-info-banner-shorten-path-from)
|
|
||||||
(eshell-info-banner--abbr-path mount t)
|
|
||||||
mount)
|
|
||||||
:size size
|
|
||||||
:used used
|
|
||||||
:percent (string-to-number
|
|
||||||
(string-trim-left percent (regexp-quote "%")))))))
|
|
||||||
partitions)))
|
|
||||||
|
|
||||||
(defun eshell-info-banner--get-mounted-partitions ()
|
(defun eshell-info-banner--get-mounted-partitions ()
|
||||||
"Detect mounted partitions on the system.
|
"Detect mounted partitions on the system.
|
||||||
|
Loading…
Reference in New Issue
Block a user