Customize which partitions to show, close #9

New variable `eshell-info-banner-partition-prefixes' now allows for
finer filtering of user partitions.
This commit is contained in:
Lucien Cartier-Tilet 2021-05-15 20:32:49 +02:00
parent 624256442f
commit e7092c5846
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
2 changed files with 34 additions and 9 deletions

View File

@ -16,7 +16,7 @@ This package is geared towards Linux in particular, I am pretty sure
it will not work on Windows, and there will probably be bugs on it will not work on Windows, and there will probably be bugs on
macOS. PR are welcome if you want to fix that! macOS. PR are welcome if you want to fix that!
* Installation * Installation
A couple of options are available for installing A couple of options are available for installing
~eshell-info-banner.el~. The first one is to clone the repository in ~eshell-info-banner.el~. The first one is to clone the repository in
your ~load-path~ and add the following to your ~.emacs~ or your ~init.el~: your ~load-path~ and add the following to your ~.emacs~ or your ~init.el~:
@ -49,27 +49,45 @@ or non-gnu elpa.
* Customizing * Customizing
A couple of variables can be edited by the user in order to configure A couple of variables can be edited by the user in order to configure
~eshell-info-banner.el~: ~eshell-info-banner.el~:
- ~eshell-info-banner-partition-prefixes~ :: Filter for which
mountpoints are to be shown to the user. By default, only partitions
mounted on a filesystem (as displayed by the command ~df -Hl~)
prefixed by ~/dev~ are shown, but you can modify it by adding other
prefixes to this list. For instance, to detect ZFS roots, you can
set its value to ~'("/dev" "zroot")~.
Default value: ~'("/dev")~.
- ~eshell-info-banner-shorten-path-from~ :: Maximum length of the mount - ~eshell-info-banner-shorten-path-from~ :: Maximum length of the mount
path of a partition before it gets abbreviated. Set it to ridiculous path of a partition before it gets abbreviated. Set it to ridiculous
numbers in order to disable it (something like ~1000~ should be more numbers in order to disable it (something like ~1000~ should be more
than enough). Default value: ~7~ than enough).
Default value: ~7~
- ~eshell-info-banner-width~ :: *Minimum* width of the banner. Be aware - ~eshell-info-banner-width~ :: *Minimum* width of the banner. Be aware
the banner will automatically select the minimal width required to the banner will automatically select the minimal width required to
display everything it wants to display if ~eshell-info-banner-width~ display everything it wants to display if ~eshell-info-banner-width~
is too small. Default value: ~80~ is too small.
Default value: ~80~
- ~eshell-info-banner-progress-bar-char~ :: Character to fill the - ~eshell-info-banner-progress-bar-char~ :: Character to fill the
progress bar with. Default value: ~=~ progress bar with.
Default value: ~=~
- ~eshell-info-banner-warning-percentage~ :: Percentage from which the - ~eshell-info-banner-warning-percentage~ :: Percentage from which the
level should be displayed as a warning. Default value: ~75~ level should be displayed as a warning.
Default value: ~75~
- ~eshell-info-banner-critical-percentage~ :: Percentage from which the - ~eshell-info-banner-critical-percentage~ :: Percentage from which the
level should be displayed as critical. Default value ~90~ level should be displayed as critical.
Default value ~90~
- ~eshell-info-banner-tramp-aware~ :: When using Eshell through TRAMP, - ~eshell-info-banner-tramp-aware~ :: When using Eshell through TRAMP,
you can decide whether ~eshell-info-banner~ will display information you can decide whether ~eshell-info-banner~ will display information
about the remote system you are connected to or only display about the remote system you are connected to or only display
information about your local system. To achieve this, set information about your local system. To achieve this, set
~eshell-info-banner-tramp-aware~ to ~t~ to display information on the ~eshell-info-banner-tramp-aware~ to ~t~ to display information on the
remote system or to ~nil~ to keep local information only. Default remote system or to ~nil~ to keep local information only.
value ~t~.
Default value ~t~.
Dont like the colors used by the package? They should follow by Dont like the colors used by the package? They should follow by
default your theme, but you can customize the following faces: default your theme, but you can customize the following faces:

View File

@ -77,6 +77,11 @@
:group 'eshell-info-banner :group 'eshell-info-banner
:type 'float) :type 'float)
(defcustom eshell-info-banner-partition-prefixes '("/dev")
"List of prefixes for detecting which partitions to display."
:group 'eshell-info-banner
:type 'list)
; Faces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Faces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defface eshell-info-banner-background-face (defface eshell-info-banner-background-face
@ -155,7 +160,9 @@ Return detected partitions as a list of structs."
(used (nth 2 partition)) (used (nth 2 partition))
(percent (nth 4 partition)) (percent (nth 4 partition))
(mount (nth 5 partition))) (mount (nth 5 partition)))
(when (string-prefix-p "/dev" filesystem t) (when (seq-some (lambda (prefix)
(string-prefix-p prefix filesystem t))
eshell-info-banner-partition-prefixes)
(make-eshell-info-banner--mounted-partitions (make-eshell-info-banner--mounted-partitions
:path (if (> (length mount) eshell-info-banner-shorten-path-from) :path (if (> (length mount) eshell-info-banner-shorten-path-from)
(eshell-info-banner--abbr-path mount t) (eshell-info-banner--abbr-path mount t)