Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
SqrtMinusOne | 2f4e59ea7a | |
SqrtMinusOne | 987e69a662 | |
SqrtMinusOne | 6b464b1b73 | |
Lucien Cartier-Tilet | b7f2bfc013 | |
Lucien Cartier-Tilet | fcc88df86a | |
Lucien Cartier-Tilet | 4ffaf329db |
|
@ -109,6 +109,15 @@ A couple of variables can be edited by the user in order to configure
|
|||
set its value to ~("/dev" "zroot")~.
|
||||
|
||||
Default value: ~("/dev")~
|
||||
- ~eshell-info-banner-filter-duplicate-partitions~ :: Try to filter
|
||||
out duplicate partitions. Two partitions are considered duplicate if
|
||||
they have the same size and amount of space used.
|
||||
|
||||
Default value: ~nil~
|
||||
- ~eshell-info-banner-exclude-partitions~ :: List of pattens to exclude
|
||||
from the partition list.
|
||||
|
||||
Default value: ~nil~
|
||||
- ~eshell-info-banner-shorten-path-from~ :: Maximum length of the mount
|
||||
path of a partition before it gets abbreviated. Set it to ridiculous
|
||||
numbers in order to disable it (something like ~1000~ should be more
|
||||
|
|
|
@ -139,6 +139,21 @@
|
|||
:group 'eshell-info-banner
|
||||
: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)
|
||||
|
||||
(defcustom eshell-info-banner-exclude-partitions nil
|
||||
"List of patterns to exclude from the partition list.
|
||||
|
||||
Patterns are matched against the partition name with
|
||||
`string-match-p'."
|
||||
:group 'eshell-info-banner
|
||||
:type '(repeat string))
|
||||
|
||||
(defmacro eshell-info-banner--executable-find (program)
|
||||
"Find PROGRAM executable, possibly on a remote machine.
|
||||
|
@ -417,24 +432,52 @@ Return detected partitions as a list of structs. See
|
|||
chosen. Relies on the `df' command."
|
||||
(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.
|
||||
|
||||
Return detected partitions as a list of structs."
|
||||
(if eshell-info-banner-use-duf
|
||||
(eshell-info-banner--get-mounted-partitions-duf)
|
||||
(pcase system-type
|
||||
((or 'gnu 'gnu/linux 'gnu/kfreebsd 'berkeley-unix)
|
||||
(eshell-info-banner--get-mounted-partitions-gnu))
|
||||
((or 'ms-dos 'windows-nt 'cygwin)
|
||||
(eshell-info-banner--get-mounted-partitions-windows))
|
||||
('darwin
|
||||
(eshell-info-banner--get-mounted-partitions-darwin))
|
||||
(other
|
||||
(progn
|
||||
((or 'gnu 'gnu/linux 'gnu/kfreebsd 'berkeley-unix)
|
||||
(eshell-info-banner--get-mounted-partitions-gnu))
|
||||
((or 'ms-dos 'windows-nt 'cygwin)
|
||||
(eshell-info-banner--get-mounted-partitions-windows))
|
||||
('darwin
|
||||
(eshell-info-banner--get-mounted-partitions-darwin))
|
||||
(other
|
||||
(progn
|
||||
(warn "Partition detection for %s not yet supported." other)
|
||||
nil)))))
|
||||
|
||||
(defun eshell-info-banner--get-mounted-partitions ()
|
||||
"Detect mounted partitions on the system.
|
||||
|
||||
Take `eshell-info-banner-filter-duplicate-partitions' and
|
||||
`eshell-info-banner-exclude-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))))
|
||||
(when eshell-info-banner-exclude-partitions
|
||||
(setq partitions
|
||||
(seq-filter (lambda (partition)
|
||||
(let ((path (eshell-info-banner--mounted-partitions-path
|
||||
partition)))
|
||||
(not (seq-some
|
||||
(lambda (pattern)
|
||||
(string-match-p pattern path))
|
||||
eshell-info-banner-exclude-partitions))))
|
||||
partitions)))
|
||||
partitions))
|
||||
|
||||
(defun eshell-info-banner--partition-to-string (partition text-padding bar-length)
|
||||
"Display a progress bar showing how full a PARTITION is.
|
||||
|
||||
|
|
Loading…
Reference in New Issue