diff --git a/README.md b/README.md index 0f33fd4..bd6af07 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ - ✅ Automatic unit conversion (Bytes, KB, MB, GB) - ✅ **Sorting by size**: Folders first (largest to smallest), then files (largest to smallest) - ✅ Colored output (folders in yellow, files in green) with emojis (📁 / 📄) +- ✅ **Total summary**: Displays directory count, file count, and overall total size at the bottom - ✅ Can be used like `ls` in any folder - ✅ High-performance stack-based directory traversal to process large trees efficiently @@ -75,18 +76,19 @@ lss -All ## 📸 Example Output ``` -Dizin: C:\Users\Muhammed +Directory: C:\Users\Muhammed ================================================================================ -TIP ISIM BOYUT +TYPE NAME SIZE ================================================================================ -📁 KLS .cache 4.13 GB -📁 KLS .local 5.66 GB -📁 KLS .ollama 4.36 GB -📁 KLS Apple 69.42 GB -📁 KLS anaconda3 4.47 GB -📄 DSY install.ps1 21.57 KB -📄 DSY oracle-1 3.30 KB +📁 DIR .cache 4.13 GB +📁 DIR .local 5.66 GB +📁 DIR .ollama 4.36 GB +📁 DIR Apple 69.42 GB +📁 DIR anaconda3 4.47 GB +📄 FILE install.ps1 21.57 KB +📄 FILE oracle-1 3.30 KB ================================================================================ +Total: 5 Directories, 2 Files | Total Size: 88.04 GB ``` ## 🛠️ Requirements @@ -129,6 +131,7 @@ Don't forget to give a star if you find the project useful! - ✅ Otomatik birim dönüşümü (Bytes, KB, MB, GB) - ✅ **Boyuta göre sıralama**: Önce klasörler (büyükten küçüğe), sonra dosyalar (büyükten küçüğe) - ✅ Emojili (📁 / 📄) ve renkli çıktı (klasörler sarı, dosyalar yeşil) +- ✅ **Özet bilgi**: En altta toplam klasör sayısını, dosya sayısını ve genel toplam boyutu gösterir - ✅ Her klasörde `ls` gibi kullanılabilir - ✅ Büyük dizin ağaçlarını hızlıca işlemek için yüksek performanslı stack tabanlı dizin tarama yapısı @@ -179,18 +182,19 @@ lss -All ## 📸 Örnek Çıktı ``` -Dizin: C:\Users\Muhammed +Directory: C:\Users\Muhammed ================================================================================ -TIP ISIM BOYUT +TYPE NAME SIZE ================================================================================ -📁 KLS .cache 4.13 GB -📁 KLS .local 5.66 GB -📁 KLS .ollama 4.36 GB -📁 KLS Apple 69.42 GB -📁 KLS anaconda3 4.47 GB -📄 DSY install.ps1 21.57 KB -📄 DSY oracle-1 3.30 KB +📁 DIR .cache 4.13 GB +📁 DIR .local 5.66 GB +📁 DIR .ollama 4.36 GB +📁 DIR Apple 69.42 GB +📁 DIR anaconda3 4.47 GB +📄 FILE install.ps1 21.57 KB +📄 FILE oracle-1 3.30 KB ================================================================================ +Total: 5 Directories, 2 Files | Total Size: 88.04 GB ``` ## 🛠️ Gereksinimler diff --git a/install.ps1 b/install.ps1 index 7b5f89f..be533b5 100644 --- a/install.ps1 +++ b/install.ps1 @@ -24,7 +24,7 @@ if ($profileContent -match "function lss") { if ($response -eq "E") { # Eski lss fonksiyonunu kaldır - $profileContent = $profileContent -replace "(?ms)# PowerShell Profiline.*?^}", "" + $profileContent = $profileContent -replace "(?ms)# PowerShell Profiline.*?^function lss\b.*?^}", "" $profileContent = $profileContent.Trim() # Yeni fonksiyonu ekle diff --git a/lss.ps1 b/lss.ps1 index d7b4e5e..68bae3e 100644 --- a/lss.ps1 +++ b/lss.ps1 @@ -55,17 +55,18 @@ function Format-LssSize { param( [long]$Bytes ) + $culture = [System.Globalization.CultureInfo]::InvariantCulture if ($Bytes -ge 1GB) { - return "{0:N2} GB" -f ($Bytes / 1GB) + return [string]::Format($culture, "{0:N2} GB", $Bytes / 1GB) } elseif ($Bytes -ge 1MB) { - return "{0:N2} MB" -f ($Bytes / 1MB) + return [string]::Format($culture, "{0:N2} MB", $Bytes / 1MB) } elseif ($Bytes -ge 1KB) { - return "{0:N2} KB" -f ($Bytes / 1KB) + return [string]::Format($culture, "{0:N2} KB", $Bytes / 1KB) } else { - return "{0} Bytes" -f $Bytes + return [string]::Format($culture, "{0} Bytes", $Bytes) } } @@ -104,12 +105,17 @@ function lss { $resolvedPath = (Resolve-Path -Path $Path -ErrorAction SilentlyContinue).Path if (-not $resolvedPath) { $resolvedPath = $Path } - Write-Host "`nDizin: $resolvedPath" -ForegroundColor Cyan - Write-Host ("="*80) -ForegroundColor Cyan - Write-Host ("{0,-8} {1,-50} {2,15}" -f "TIP", "ISIM", "BOYUT") -ForegroundColor Cyan - Write-Host ("="*80) -ForegroundColor Cyan + Write-Host "`nDirectory: $resolvedPath" -ForegroundColor Cyan + Write-Host ("="*80) -ForegroundColor DarkGray + Write-Host ("{0,-8} {1,-50} {2,15}" -f "TYPE", "NAME", "SIZE") -ForegroundColor Cyan + Write-Host ("="*80) -ForegroundColor DarkGray + + [long]$totalSize = 0 + [int]$dirCount = 0 + [int]$fileCount = 0 foreach ($entry in $sorted) { + $totalSize += $entry.Size $formattedSize = Format-LssSize -Bytes $entry.Size $displayName = $entry.Item.Name if ($displayName.Length -gt 48) { @@ -117,11 +123,15 @@ function lss { } if ($entry.IsFolder) { - Write-Host ("{0,-8} {1,-50} {2,15}" -f "📁 KLS", $displayName, $formattedSize) -ForegroundColor Yellow + $dirCount++ + Write-Host ("{0,-8} {1,-50} {2,15}" -f "📁 DIR", $displayName, $formattedSize) -ForegroundColor Yellow } else { - Write-Host ("{0,-8} {1,-50} {2,15}" -f "📄 DSY", $displayName, $formattedSize) -ForegroundColor Green + $fileCount++ + Write-Host ("{0,-8} {1,-50} {2,15}" -f "📄 FILE", $displayName, $formattedSize) -ForegroundColor Green } } - Write-Host ("="*80 + "`n") -ForegroundColor Cyan + Write-Host ("="*80) -ForegroundColor DarkGray + $formattedTotalSize = Format-LssSize -Bytes $totalSize + Write-Host ("Total: $dirCount Directories, $fileCount Files | Total Size: $formattedTotalSize`n") -ForegroundColor Cyan } \ No newline at end of file