commit ecda9cbfad0994b3b9d2e85054481280c0d631fb Author: Taken Date: Wed Aug 21 19:47:23 2024 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..043850c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +Modules +Scripts +powershell.config.json diff --git a/Microsoft.PowerShell_profile.ps1 b/Microsoft.PowerShell_profile.ps1 new file mode 100644 index 0000000..1c40432 --- /dev/null +++ b/Microsoft.PowerShell_profile.ps1 @@ -0,0 +1,165 @@ +Import-Module -Name PSWindowsUpdate +Import-Module -Name gsudoModule +Import-module -Name Terminal-Icons + +# aliases +Set-Alias -Name reboot -Value Restart-Computer +Set-Alias -Name shutdown -Value Stop-Computer +Set-Alias -Name st -Value streamlink +Set-Alias -Name v -Value nvim + +function randomscript { + $artDir = "$env:USERPROFILE\asciiart" + if (Test-Path $artDir -ErrorAction SilentlyContinue) { + $art = Get-ChildItem -Path $artDir | Get-Random + Get-Content -Path $art | Write-Host -ForegroundColor DarkMagenta + } +} + +function hsconnect { + netsh wlan connect name="Arc V2" +} + +function wificonnect($profilename) { + netsh wlan connect name=$profilename +} + +function lsfunc($dir) { eza -la --group-directories-first --git --git-repos --icons $dir } +Set-Alias -Name ls -Value lsfunc + +function Invoke-WinutilExtrnal { + Start-Process pwsh.exe -Verb runas -ArgumentList "-c irm https://christitus.com/win | iex" +} +function Invoke-Winutil { + Invoke-RestMethod "https://christitus.com/win" | Invoke-Expression +} +Set-Alias -Name winutil -Value Invoke-Winutil +Set-Alias -Name winutilup -Value Invoke-WinutilExtrnal + +function emd { + if (Get-Process -Name "emacs" -ErrorAction SilentlyContinue) { + Write-Host "====================================" -ForegroundColor Red + Write-Host "Emacs is already running" -ForegroundColor DarkMagenta + Write-Host "====================================" -ForegroundColor Red + return + } + emacs --daemon & +} + +function nvims($appname, $file) { + + $env:NVIM_APPNAME = $appname + + if ($file) { + nvim $file + } + else { + nvim + } + + Remove-Item -Force env:NVIM_APPNAME + +} + +function grep($pattern, $file) { + + if (-not (Test-Path $file)) { + Write-Host "====================================" -ForegroundColor Red + Write-Host "Error: $file does not exist" -ForegroundColor DarkMagenta + Write-Host "====================================" -ForegroundColor Red + return + } + + if (Test-Path $file -PathType Container) { + Write-Host "====================================" -ForegroundColor Red + Write-Host "Error: $file is a directory" -ForegroundColor DarkMagenta + Write-Host "====================================" -ForegroundColor Red + return + } + + Get-Content $file | Select-String $pattern +} +function unzip ($file) { + Write-Output("Extracting", $file, "to", $pwd) + $fullFile = Get-ChildItem -Path $pwd -Filter .\cove.zip | ForEach-Object { $_.FullName } + Expand-Archive -Path $fullFile -DestinationPath $pwd +} + +function frm($path) { + Remove-Item $path -Force +} + +function lnk($link, $target) { + New-Item -Type SymbolicLink -Path $link -Target $target +} + +Function Get-PubIP { + (Invoke-WebRequest http://ifconfig.me/ip ).Content +} + +function uptime { + Get-WmiObject win32_operatingsystem | Select-Object csname, @{LABEL='LastBootUpTime'; + EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}} +} + +function reload_profile { + & $profile +} + +function touch($file) { + "" | Out-File $file -Encoding ASCII +} + +function export($name, $value) { + set-item -force -path "env:$name" -value $value; +} + +function killall($name) { + Get-Process $name -ErrorAction SilentlyContinue | Stop-Process +} + +function pgrep($name) { + Get-Process $name +} + +function find-file($name) { + Get-ChildItem -recurse -filter "*${name}*" -ErrorAction SilentlyContinue | ForEach-Object { + $place_path = $_.directory + Write-Output "${place_path}\${_}" + } +} + +function admin + { + if ($args.Count -gt 0) + { + $argList = "& '" + $args + "'" + Start-Process "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.15.3465.0_x64__8wekyb3d8bbwe\wt.exe" -Verb runAs -ArgumentList $argList + } + else + { + Start-Process "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.15.3465.0_x64__8wekyb3d8bbwe\wt.exe" -Verb runAs + } +} +#f45873b3-b655-43a6-b217-97c00aa0db58 PowerToys CommandNotFound module + +Import-Module -Name Microsoft.WinGet.CommandNotFound +#f45873b3-b655-43a6-b217-97c00aa0db58 + +$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" +if (Test-Path($ChocolateyProfile)) { + Import-Module "$ChocolateyProfile" +} + +if (Get-Command -Name fnm -ErrorAction SilentlyContinue) { + Invoke-Expression (& { (fnm env --shell power-shell --use-on-cd | Out-String) }) +} + +if (Get-Command -Name zoxide -ErrorAction SilentlyContinue) { + Invoke-Expression (& { (zoxide init --cmd j powershell | Out-String) }) +} + +if (Get-Command -Name starship -ErrorAction SilentlyContinue) { + Invoke-Expression (&starship init powershell) +} +randomscript