Add an option to filter duplicate partitions
This commit is contained in:
parent
b7f2bfc013
commit
6b464b1b73
@ -139,6 +139,13 @@
|
|||||||
:group 'eshell-info-banner
|
:group 'eshell-info-banner
|
||||||
:type 'list)
|
:type 'list)
|
||||||
|
|
||||||
|
(defcustom eshell-info-banner-filter-duplicate-partitions nil
|
||||||
|
"Whether to filter duplicate partitions.
|
||||||
|
|
||||||
|
Two partitions are considered duplicate if they have the same
|
||||||
|
size and amount of space used."
|
||||||
|
:group 'eshell-info-banner
|
||||||
|
:type 'boolean)
|
||||||
|
|
||||||
(defmacro eshell-info-banner--executable-find (program)
|
(defmacro eshell-info-banner--executable-find (program)
|
||||||
"Find PROGRAM executable, possibly on a remote machine.
|
"Find PROGRAM executable, possibly on a remote machine.
|
||||||
@ -417,24 +424,42 @@ Return detected partitions as a list of structs. See
|
|||||||
chosen. Relies on the `df' command."
|
chosen. Relies on the `df' command."
|
||||||
(eshell-info-banner--get-mounted-partitions-df 8))
|
(eshell-info-banner--get-mounted-partitions-df 8))
|
||||||
|
|
||||||
(defun eshell-info-banner--get-mounted-partitions ()
|
(defun eshell-info-banner--get-mounted-partitions-1 ()
|
||||||
"Detect mounted partitions on the system.
|
"Detect mounted partitions on the system.
|
||||||
|
|
||||||
Return detected partitions as a list of structs."
|
Return detected partitions as a list of structs."
|
||||||
(if eshell-info-banner-use-duf
|
(if eshell-info-banner-use-duf
|
||||||
(eshell-info-banner--get-mounted-partitions-duf)
|
(eshell-info-banner--get-mounted-partitions-duf)
|
||||||
(pcase system-type
|
(pcase system-type
|
||||||
((or 'gnu 'gnu/linux 'gnu/kfreebsd 'berkeley-unix)
|
((or 'gnu 'gnu/linux 'gnu/kfreebsd 'berkeley-unix)
|
||||||
(eshell-info-banner--get-mounted-partitions-gnu))
|
(eshell-info-banner--get-mounted-partitions-gnu))
|
||||||
((or 'ms-dos 'windows-nt 'cygwin)
|
((or 'ms-dos 'windows-nt 'cygwin)
|
||||||
(eshell-info-banner--get-mounted-partitions-windows))
|
(eshell-info-banner--get-mounted-partitions-windows))
|
||||||
('darwin
|
('darwin
|
||||||
(eshell-info-banner--get-mounted-partitions-darwin))
|
(eshell-info-banner--get-mounted-partitions-darwin))
|
||||||
(other
|
(other
|
||||||
(progn
|
(progn
|
||||||
(warn "Partition detection for %s not yet supported." other)
|
(warn "Partition detection for %s not yet supported." other)
|
||||||
nil)))))
|
nil)))))
|
||||||
|
|
||||||
|
(defun eshell-info-banner--get-mounted-partitions ()
|
||||||
|
"Detect mounted partitions on the system.
|
||||||
|
|
||||||
|
Take `eshell-info-banner-filter-duplicate-partitions' into
|
||||||
|
account."
|
||||||
|
(let ((partitions (eshell-info-banner--get-mounted-partitions-1)))
|
||||||
|
(when eshell-info-banner-filter-duplicate-partitions
|
||||||
|
(setq partitions
|
||||||
|
(cl-loop for partition in partitions
|
||||||
|
with used = nil
|
||||||
|
for signature =
|
||||||
|
(format "%d-%d"
|
||||||
|
(eshell-info-banner--mounted-partitions-size partition)
|
||||||
|
(eshell-info-banner--mounted-partitions-used partition))
|
||||||
|
unless (member signature used)
|
||||||
|
collect partition and do (push signature used))))
|
||||||
|
partitions))
|
||||||
|
|
||||||
(defun eshell-info-banner--partition-to-string (partition text-padding bar-length)
|
(defun eshell-info-banner--partition-to-string (partition text-padding bar-length)
|
||||||
"Display a progress bar showing how full a PARTITION is.
|
"Display a progress bar showing how full a PARTITION is.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user