From 37656ed83cd44699dbb5545c5b77dc5cb7a3d44c Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Thu, 29 Apr 2021 12:28:07 +0200 Subject: [PATCH] Better string formatting, add partition display FIXME: All elements in a path are shortened even if not necessary --- eshell-info-banner.el | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/eshell-info-banner.el b/eshell-info-banner.el index 82cb37d..64ce297 100644 --- a/eshell-info-banner.el +++ b/eshell-info-banner.el @@ -216,12 +216,34 @@ displayed." (concat (s-pad-right text-padding "." type) ": " (eshell-info-banner--progress-bar bar-length percentage) - (format " %6s / %-5s (" + (format " %6s / %-5s (%s%%)\n" (file-size-human-readable used) - (file-size-human-readable total)) - (eshell-info-banner--with-face (number-to-string percentage) - :inherit (eshell-info-banner--get-color-percentage percentage)) - "%)\n"))) + (file-size-human-readable total) + (eshell-info-banner--with-face (number-to-string percentage) + :inherit (eshell-info-banner--get-color-percentage percentage)))))) + +(defun eshell-info-banner--display-partition (partition text-padding bar-length) + "Display a progress bar showing how full a `PARTITION' is. + +`BAR-LENGTH' represents the total length of the progress bar, +while `TEXT-PADDING' indicates how many dots are to be put +between the partition’s name and the colon following it. + +See also `eshell-info-banner--display-memory'." + (let ((percentage (eshell-info-banner--mounted-partitions-percent partition))) + (concat (s-pad-right text-padding "." + (eshell-info-banner--with-face (eshell-info-banner--mounted-partitions-path partition) + :weight 'bold)) + ": " + (eshell-info-banner--progress-bar bar-length percentage) + (format " %6s/%-5s (%s%%)\n" + (eshell-info-banner--mounted-partitions-used partition) + (eshell-info-banner--mounted-partitions-size partition) + (eshell-info-banner--with-face + (number-to-string percentage) + :inherit (eshell-info-banner--get-color-percentage percentage)))))) + + (provide 'eshell-info-banner)