File tree Expand file tree Collapse file tree 1 file changed +5
-16
lines changed
G33kShell.Desktop/Terminal/Commands Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change 88// about your modifications. Your contributions are valued!
99//
1010// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND.
11- using System ;
11+
1212using System . IO ;
1313using System . Linq ;
1414using System . Threading . Tasks ;
@@ -25,21 +25,10 @@ protected override Task<bool> Run(ITerminalState state)
2525 var drives = DriveInfo . GetDrives ( ) . Where ( d => d . IsReady && d . DriveType == DriveType . Fixed ) ;
2626 foreach ( var drive in drives )
2727 {
28- var totalSpace = drive . TotalSize ;
29- var freeSpace = drive . AvailableFreeSpace ;
30- var usagePercentage = ( double ) ( totalSpace - freeSpace ) / totalSpace ;
31-
32- // Build the size string and calculate its length.
33- var infoText = drive . TotalSize . ToSize ( ) ;
34-
35- // Progress bar width calculation.
36- var totalWidth = state . CliPrompt . Width ;
37- var fixedTextWidth = drive . Name . Length + infoText . Length + 5 ;
38- var progressWidth = totalWidth - fixedTextWidth ;
39- var filledWidth = ( int ) Math . Round ( progressWidth * usagePercentage ) ;
40-
41- // Display drive info.
42- WriteLine ( $ "{ drive . Name } [{ new string ( '=' , filledWidth ) . PadRight ( progressWidth , '.' ) } ] { infoText } ") ;
28+ var usagePercent = ( double ) ( drive . TotalSize - drive . AvailableFreeSpace ) / drive . TotalSize ;
29+ var s = $ "[{ drive . Name } ] _ { usagePercent : P0} │ { drive . TotalSize . ToSize ( ) } ";
30+ s = s . Replace ( "_" , usagePercent . ToProgressBar ( state . CliPrompt . Width - s . Length ) ) ;
31+ WriteLine ( s ) ;
4332 }
4433 return Task . FromResult ( true ) ;
4534 }
You can’t perform that action at this time.
0 commit comments