$env:src = "$HOME\src"
-$env:dotfiles = "$HOME\dotfiles"
+$env:dotfiles = Join-Path $HOME "dotfiles"
+$env:journal = Join-Path $HOME "Journal"
+$env:nvim = Join-Path $HOME "\AppData\Local\nvim"
+
+if($IsWindows) {
+ $env:journal = Join-Path $HOME "Box\Journal"
+ $env:nvim = Join-Path $HOME "\AppData\Local\nvim"
+}
+
+
Import-Module $env:dotfiles\psmodules\add_to_profile.psm1
Add-ToProfile $env:dotfiles\files\paths.ps1
Add-ToProfile $env:dotfiles\files\env.ps1
New-Alias today Get-JournalAgenda
function journal {
param(
+ [ValidateSet('limited','shared','journal', 'dotfiles', 'nvim')]
+ [string]$key,
[switch]$limited = $false,
- [switch]$shared = $false
+ [switch]$shared = $false,
+ [switch]$dotfiles = $false
)
- $path = "$HOME\Box\Journal"
- if($limited) {
- $path = "$HOME\Box\SecDevLimited"
+ $path = $journal
+ switch($key){
+ 'limited' { $path = "$HOME\Box\SecDevLimited" }
+ 'shared' { $path = "$HOME\Box\Privacy & Cybersecurity\Cybersecurity Development" }
+ 'journal' { $path = "$HOME\Box\Journal" }
+ 'dotfiles' { $path = $env:dotfiles }
+ 'nvim' { $path = $env:nvim }
}
- if($shared) {
- $path = "$HOME\Box\Privacy & Cybersecurity\Cybersecurity Development"
- }
- nvim $path
+ cd $path; nvim $path
}
+
function dotfiles {
nvim "$HOME\dotfiles"
}
+function open {
+ param (
+ [string]$searchText
+ )
+ $directories = @(
+ "$HOME\Box\Journal",
+ "$HOME\Box\SecDevLimited",
+ "$HOME\Box\Privacy & Cybersecurity\Cybersecurity Development"
+ )
+
+ $totalFiles = 0
+ $processedFiles = 0
+
+ foreach ($directory in $directories) {
+ if (Test-Path $directory) {
+ $totalFiles += (Get-ChildItem -Path $directory -Recurse -File).Count
+ } else {
+ Write-Host "Directory '$directory' does not exist."
+ }
+ }
+
+ $resultFiles = @()
+ $textFileExtensions = @(".txt", ".log", ".csv", ".json", ".xml", ".md")
+ foreach ($directory in $directories) {
+ Get-ChildItem -Path $directory -Recurse -File | Where-Object { $textFileExtensions -contains $_.Extension } | ForEach-Object {
+ $fileContent = Get-Content -Path $_.FullName -Raw
+
+ if ($fileContent -match $searchText) {
+ $resultFiles += $_.FullName
+ }
+ $processedFiles++
+ Write-Progress -Activity "Searching Files" -Status "$processedFiles / $totalFiles files processed" -PercentComplete (($processedFiles / $totalFiles) * 100)
+ }
+ }
+ nvim $resultFiles
+}
+
+
# Vi
New-Alias vi nvim
New-Alias vim nvim