From 57cfb986dca2a0e087336506ffe251e52b07631a Mon Sep 17 00:00:00 2001 From: Tomasz Kostrzewa Date: Tue, 5 Mar 2024 23:03:57 +0100 Subject: [PATCH] modified: RdzeN-Profile.ps1 new file: functions/Get-FileSize new file: functions/Get-FileSize copy modified: functions/prompt.ps1 --- RdzeN-Profile.ps1 | 5 +++-- functions/Get-FileSize | 23 +++++++++++++++++++++++ functions/Get-FileSize copy | 21 +++++++++++++++++++++ functions/prompt.ps1 | 5 ++++- 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 functions/Get-FileSize create mode 100644 functions/Get-FileSize copy diff --git a/RdzeN-Profile.ps1 b/RdzeN-Profile.ps1 index 51c91da..9562aca 100644 --- a/RdzeN-Profile.ps1 +++ b/RdzeN-Profile.ps1 @@ -48,10 +48,11 @@ Get-ChildItem $path_gitea_powershell_profile_functions | ForEach-Object { # 4. list functions $functions = Get-ChildItem $path_gitea_powershell_profile_functions | Sort-Object for ($i = 0; $i -lt $functions.Count; $i++) { - Write-Host "$i)`t$(($functions[$i].Name).Replace('.ps1',''))" + Write-Host "$i" -NoNewline -ForegroundColor Cyan + write-host ")`t" -NoNewline -ForegroundColor Blue + write-host "$(($functions[$i].Name).Replace('.ps1',''))" -ForegroundColor Cyan } - # 97. Override profile Override-Profile diff --git a/functions/Get-FileSize b/functions/Get-FileSize new file mode 100644 index 0000000..77a719d --- /dev/null +++ b/functions/Get-FileSize @@ -0,0 +1,23 @@ +# gitea.RdzeN.net +# +# Get filesize. + +function Get-FileSize { + param ( + [string]$FilePath + ) + + $fileInfo = Get-Item $FilePath + $fileSizeBytes = $fileInfo.Length + + $fileSizeKB = [math]::Round($fileSizeBytes / 1KB, 2) + $fileSizeMB = [math]::Round($fileSizeBytes / 1MB, 2) + $fileSizeGB = [math]::Round($fileSizeBytes / 1GB, 2) + + return @{ + "Bytes" = $fileSizeBytes + "KB" = $fileSizeKB + "MB" = $fileSizeMB + "GB" = $fileSizeGB + } +} diff --git a/functions/Get-FileSize copy b/functions/Get-FileSize copy new file mode 100644 index 0000000..8b43ac6 --- /dev/null +++ b/functions/Get-FileSize copy @@ -0,0 +1,21 @@ +# gitea.RdzeN.net +# +# Get Object Count. + +function Get-ObjectCount { + param ( + [string]$Path, + [switch]$Recurse + ) + + $items = Get-ChildItem $Path -Recurse:$Recurse + $count = $items.Count + + return $count +} + +if ($Recurse) { + Write-Host "Liczba obiektów w katalogu '$folderPath' i podkatalogach: $objectCount" +} else { + Write-Host "Liczba obiektów w katalogu '$folderPath': $objectCount" +} \ No newline at end of file diff --git a/functions/prompt.ps1 b/functions/prompt.ps1 index f8b9573..c9f35ec 100644 --- a/functions/prompt.ps1 +++ b/functions/prompt.ps1 @@ -1,3 +1,6 @@ +# gitea.RdzeN.net +# +# custom prompt for PS. function prompt { Write-Host "[" -NoNewline -ForegroundColor Blue @@ -15,7 +18,7 @@ function prompt Write-Host "]" -NoNewline -ForegroundColor Blue Write-Host " " -NoNewline -ForegroundColor Black Write-Host "[" -NoNewline -ForegroundColor Blue - Write-Host "$($PWD)" -NoNewline -ForegroundColor Cyan + Write-Host "$($PWD.ProviderPath)" -NoNewline -ForegroundColor Cyan Write-Host "]" -NoNewline -ForegroundColor Blue Write-Host ""