Updated config

This commit is contained in:
2024-10-18 11:48:05 +02:00
parent 45ff5e1e5f
commit 095f723768

View File

@@ -1,18 +1,24 @@
if (Get-Module -ListAvailable -Name PSWindowsUpdate) { if (Get-Module -ListAvailable -Name PSWindowsUpdate)
{
Import-Module -Name PSWindowsUpdate Import-Module -Name PSWindowsUpdate
} else { } else
{
Write-Host "PSWindowsUpdate module not found" -ForegroundColor Red Write-Host "PSWindowsUpdate module not found" -ForegroundColor Red
} }
if (Get-Module -ListAvailable -Name gsudoModule) { if (Get-Module -ListAvailable -Name gsudoModule)
{
Import-Module -Name gsudoModule Import-Module -Name gsudoModule
} else { } else
{
Write-Host "gsudoModule module not found" -ForegroundColor Red Write-Host "gsudoModule module not found" -ForegroundColor Red
} }
if (Get-Module -ListAvailable -Name Terminal-Icons) { if (Get-Module -ListAvailable -Name Terminal-Icons)
{
Import-Module -Name Terminal-Icons Import-Module -Name Terminal-Icons
} else { } else
{
Write-Host "Terminal-Icons module not found" -ForegroundColor Red Write-Host "Terminal-Icons module not found" -ForegroundColor Red
} }
@@ -21,37 +27,61 @@ Set-Alias -Name reboot -Value Restart-Computer
Set-Alias -Name shutdown -Value Stop-Computer Set-Alias -Name shutdown -Value Stop-Computer
Set-Alias -Name st -Value streamlink Set-Alias -Name st -Value streamlink
Set-Alias -Name v -Value nvim Set-Alias -Name v -Value nvim
Set-Alias -Name cat -Value batcat
function randomscript { function batcat($file)
{
bat $file --style=plain
}
function randomscript
{
$artDir = "$env:USERPROFILE\asciiart" $artDir = "$env:USERPROFILE\asciiart"
if (Test-Path $artDir -ErrorAction SilentlyContinue) { if (Test-Path $artDir -ErrorAction SilentlyContinue)
{
$art = Get-ChildItem -Path $artDir | Get-Random $art = Get-ChildItem -Path $artDir | Get-Random
Get-Content -Path $art | Write-Host -ForegroundColor DarkMagenta Get-Content -Path $art | Write-Host -ForegroundColor DarkMagenta
} }
} }
function hsconnect { function Get-Weather($location)
{
# Invoke-RestMethod wttr.in/$location"?2FQ"
Invoke-RestMethod (-join("wttr.in/", $location, "?2FQ"))
}
Set-Alias -Name weather -Value Get-Weather
function hsconnect
{
netsh wlan connect name="Arc V2" netsh wlan connect name="Arc V2"
} }
function wificonnect($profilename) { function wificonnect($profilename)
{
netsh wlan connect name=$profilename netsh wlan connect name=$profilename
} }
function lsfunc($dir) { eza -la --group-directories-first --git --git-repos --icons $dir } function lsfunc($dir)
{ eza -la --group-directories-first --git --git-repos --icons $dir
}
Set-Alias -Name ls -Value lsfunc Set-Alias -Name ls -Value lsfunc
function Invoke-WinutilExtrnal { function Invoke-WinutilExtrnal
{
Start-Process pwsh.exe -Verb runas -ArgumentList "-c irm https://christitus.com/win | iex" Start-Process pwsh.exe -Verb runas -ArgumentList "-c irm https://christitus.com/win | iex"
} }
function Invoke-Winutil { function Invoke-Winutil
{
Invoke-RestMethod "https://christitus.com/win" | Invoke-Expression Invoke-RestMethod "https://christitus.com/win" | Invoke-Expression
} }
Set-Alias -Name winutil -Value Invoke-Winutil Set-Alias -Name winutil -Value Invoke-Winutil
Set-Alias -Name winutilup -Value Invoke-WinutilExtrnal Set-Alias -Name winutilup -Value Invoke-WinutilExtrnal
function emd { function emd
if (Get-Process -Name "emacs" -ErrorAction SilentlyContinue) { {
if (Get-Process -Name "emacs" -ErrorAction SilentlyContinue)
{
Write-Host "====================================" -ForegroundColor Red Write-Host "====================================" -ForegroundColor Red
Write-Host "Emacs is already running" -ForegroundColor DarkMagenta Write-Host "Emacs is already running" -ForegroundColor DarkMagenta
Write-Host "====================================" -ForegroundColor Red Write-Host "====================================" -ForegroundColor Red
@@ -60,14 +90,16 @@ function emd {
emacs --daemon & emacs --daemon &
} }
function nvims($appname, $file) { function nvims($appname, $file)
{
$env:NVIM_APPNAME = $appname $env:NVIM_APPNAME = $appname
if ($file) { if ($file)
{
nvim $file nvim $file
} } else
else { {
nvim nvim
} }
@@ -75,16 +107,19 @@ function nvims($appname, $file) {
} }
function grep($pattern, $file) { function grep($pattern, $file)
{
if (-not (Test-Path $file)) { if (-not (Test-Path $file))
{
Write-Host "====================================" -ForegroundColor Red Write-Host "====================================" -ForegroundColor Red
Write-Host "Error: $file does not exist" -ForegroundColor DarkMagenta Write-Host "Error: $file does not exist" -ForegroundColor DarkMagenta
Write-Host "====================================" -ForegroundColor Red Write-Host "====================================" -ForegroundColor Red
return return
} }
if (Test-Path $file -PathType Container) { if (Test-Path $file -PathType Container)
{
Write-Host "====================================" -ForegroundColor Red Write-Host "====================================" -ForegroundColor Red
Write-Host "Error: $file is a directory" -ForegroundColor DarkMagenta Write-Host "Error: $file is a directory" -ForegroundColor DarkMagenta
Write-Host "====================================" -ForegroundColor Red Write-Host "====================================" -ForegroundColor Red
@@ -93,50 +128,62 @@ function grep($pattern, $file) {
Get-Content $file | Select-String $pattern Get-Content $file | Select-String $pattern
} }
function unzip ($file) { function unzip ($file)
{
Write-Output("Extracting", $file, "to", $pwd) Write-Output("Extracting", $file, "to", $pwd)
$fullFile = Get-ChildItem -Path $pwd -Filter .\cove.zip | ForEach-Object { $_.FullName } $fullFile = Get-ChildItem -Path $pwd -Filter .\cove.zip | ForEach-Object { $_.FullName }
Expand-Archive -Path $fullFile -DestinationPath $pwd Expand-Archive -Path $fullFile -DestinationPath $pwd
} }
function frm($path) { function frm($path)
{
Remove-Item $path -Force Remove-Item $path -Force
} }
function lnk($link, $target) { function lnk($link, $target)
{
New-Item -Type SymbolicLink -Path $link -Target $target New-Item -Type SymbolicLink -Path $link -Target $target
} }
Function Get-PubIP { Function Get-PubIP
{
(Invoke-WebRequest http://ifconfig.me/ip ).Content (Invoke-WebRequest http://ifconfig.me/ip ).Content
} }
function uptime { function uptime
{
Get-WmiObject win32_operatingsystem | Select-Object csname, @{LABEL='LastBootUpTime'; Get-WmiObject win32_operatingsystem | Select-Object csname, @{LABEL='LastBootUpTime';
EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}} EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}
}
} }
function reload_profile { function reload_profile
{
& $profile & $profile
} }
function touch($file) { function touch($file)
{
"" | Out-File $file -Encoding ASCII "" | Out-File $file -Encoding ASCII
} }
function export($name, $value) { function export($name, $value)
{
set-item -force -path "env:$name" -value $value; set-item -force -path "env:$name" -value $value;
} }
function killall($name) { function killall($name)
{
Get-Process $name -ErrorAction SilentlyContinue | Stop-Process Get-Process $name -ErrorAction SilentlyContinue | Stop-Process
} }
function pgrep($name) { function pgrep($name)
{
Get-Process $name Get-Process $name
} }
function find-file($name) { function find-file($name)
{
Get-ChildItem -recurse -filter "*${name}*" -ErrorAction SilentlyContinue | ForEach-Object { Get-ChildItem -recurse -filter "*${name}*" -ErrorAction SilentlyContinue | ForEach-Object {
$place_path = $_.directory $place_path = $_.directory
Write-Output "${place_path}\${_}" Write-Output "${place_path}\${_}"
@@ -149,8 +196,7 @@ function admin
{ {
$argList = "& '" + $args + "'" $argList = "& '" + $args + "'"
Start-Process "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.15.3465.0_x64__8wekyb3d8bbwe\wt.exe" -Verb runAs -ArgumentList $argList Start-Process "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.15.3465.0_x64__8wekyb3d8bbwe\wt.exe" -Verb runAs -ArgumentList $argList
} } else
else
{ {
Start-Process "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.15.3465.0_x64__8wekyb3d8bbwe\wt.exe" -Verb runAs Start-Process "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.15.3465.0_x64__8wekyb3d8bbwe\wt.exe" -Verb runAs
} }
@@ -161,19 +207,36 @@ Import-Module -Name Microsoft.WinGet.CommandNotFound
#f45873b3-b655-43a6-b217-97c00aa0db58 #f45873b3-b655-43a6-b217-97c00aa0db58
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) { if (Test-Path($ChocolateyProfile))
{
Import-Module "$ChocolateyProfile" Import-Module "$ChocolateyProfile"
} }
if (Get-Command -Name fnm -ErrorAction SilentlyContinue) { $ENV:FZF_DEFAULT_OPTS=@"
--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8
--color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc
--color=marker:#b4befe,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8
--color=selected-bg:#45475a
--multi
"@
if (Get-Command -Name direnv -ErrorAction SilentlyContinue)
{
Invoke-Expression "$(direnv hook pwsh)"
}
if (Get-Command -Name fnm -ErrorAction SilentlyContinue)
{
Invoke-Expression (& { (fnm env --shell power-shell --use-on-cd | Out-String) }) Invoke-Expression (& { (fnm env --shell power-shell --use-on-cd | Out-String) })
} }
if (Get-Command -Name zoxide -ErrorAction SilentlyContinue) { if (Get-Command -Name zoxide -ErrorAction SilentlyContinue)
{
Invoke-Expression (& { (zoxide init --cmd j powershell | Out-String) }) Invoke-Expression (& { (zoxide init --cmd j powershell | Out-String) })
} }
if (Get-Command -Name starship -ErrorAction SilentlyContinue) { if (Get-Command -Name starship -ErrorAction SilentlyContinue)
{
Invoke-Expression (&starship init powershell) Invoke-Expression (&starship init powershell)
} }
randomscript randomscript