From f31a592d0034e8741f55b5a5d178cb2829dba89e Mon Sep 17 00:00:00 2001 From: Tomasz Kostrzewa Date: Wed, 6 Mar 2024 00:25:22 +0100 Subject: [PATCH] modified: RdzeN-Profile.ps1 modified: functions/Find-Notepadpp.ps1 modified: functions/Find-VSCode.ps1 new file: functions/Open-Folder.ps1 --- RdzeN-Profile.ps1 | 22 +++++++++++++++++++--- functions/Find-Notepadpp.ps1 | 6 +++--- functions/Find-VSCode.ps1 | 6 +++--- functions/Open-Folder.ps1 | 6 ++++++ 4 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 functions/Open-Folder.ps1 diff --git a/RdzeN-Profile.ps1 b/RdzeN-Profile.ps1 index 83c886a..eaf3864 100644 --- a/RdzeN-Profile.ps1 +++ b/RdzeN-Profile.ps1 @@ -103,11 +103,27 @@ if ($functions_to_pull.Count -gt 0) { } # 4. List functions -$functions = Get-ChildItem $path_gitea_powershell_profile_functions | Sort-Object -for ($i = 0; $i -lt $functions.Count; $i++) { +# Lokalizacja plików +$path_to_search = "$path_gitea_powershell_profile_functions\*" + +# Zmienna do przechowywania wyników +$found_functions = @() + +# Szukanie funkcji w plikach +Get-ChildItem $path_to_search | ForEach-Object { + $file_content = Get-Content $_.FullName -Raw + $matches = [Regex]::Matches($file_content, '(?<=function\s).*?(?={)') + foreach ($match in $matches) { + $found_functions += $match.Value.Trim() + } +} + +$found_functions = $found_functions | Sort-Object + +for ($i = 0; $i -lt $found_functions.Count; $i++) { Write-Host "$($i+1)" -NoNewline -ForegroundColor Cyan Write-Host ")`t" -NoNewline -ForegroundColor Blue - Write-Host "$(($functions[$i].Name).Replace('.ps1',''))" -ForegroundColor Cyan + Write-Host "$($found_functions[$i])" -ForegroundColor Cyan } # 99. Prompt profile loaded diff --git a/functions/Find-Notepadpp.ps1 b/functions/Find-Notepadpp.ps1 index 755821a..3522cb2 100644 --- a/functions/Find-Notepadpp.ps1 +++ b/functions/Find-Notepadpp.ps1 @@ -2,7 +2,7 @@ # Find notepad++ # use notepad++ as editor -function find-notepadpp { +function Find-Notepadpp { $a = Get-ChildItem -Path $env:ProgramFiles -Filter "notepad++.exe" -Recurse -File -ErrorAction SilentlyContinue $b = Get-ChildItem -Path ${env:ProgramFiles(x86)} -Filter "notepad++.exe" -Recurse -File -ErrorAction SilentlyContinue @@ -15,9 +15,9 @@ function find-notepadpp { return $notepadpp } } -$notepadpp = find-notepadpp +$notepadpp = Find-Notepadpp if ($notepadpp -ne $null) { - function editn { + function EditN { param ( $filepath ) diff --git a/functions/Find-VSCode.ps1 b/functions/Find-VSCode.ps1 index 06e3f90..00c0ce3 100644 --- a/functions/Find-VSCode.ps1 +++ b/functions/Find-VSCode.ps1 @@ -2,7 +2,7 @@ # Find notepad++ # use notepad++ as editor -function find-vscode { +function Find-Vscode { $a = Get-ChildItem -Path $env:ProgramFiles -Filter "Code.exe" -Recurse -File -ErrorAction SilentlyContinue $b = Get-ChildItem -Path ${env:ProgramFiles(x86)} -Filter "Code.exe" -Recurse -File -ErrorAction SilentlyContinue @@ -15,9 +15,9 @@ function find-vscode { return $vscode } } -$vscode = find-vscode +$vscode = Find-Vscode if ($vscode -ne $null) { - function editv { + function EditV { param ( $filepath ) diff --git a/functions/Open-Folder.ps1 b/functions/Open-Folder.ps1 new file mode 100644 index 0000000..063d19e --- /dev/null +++ b/functions/Open-Folder.ps1 @@ -0,0 +1,6 @@ +# gitea.RdzeN.net +# Open Folder in Explorer +function Open-Folder { + param ([string]$path = $PWD) + Start-Process Explorer -ArgumentList $path +} \ No newline at end of file