Last active
October 31, 2024 02:19
-
-
Save ril3y/f1a97c114cae80dc80471f0bfc9de611 to your computer and use it in GitHub Desktop.
This is my personal ps1 profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$env:VIRTUAL_ENV_DISABLE_PROMPT = "1" | |
& "C:\Users\riley\myvenv\Scripts\Activate.ps1" | |
try { | |
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression | |
} catch { | |
Write-Host "Failed to initialize Oh-My-Posh: $_" -ForegroundColor Red | |
} | |
function Disable-NewsAndInterests { | |
# Disable Windows Widgets by setting the registry value | |
$registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" | |
$valueName = "TaskbarDa" | |
$value = 0 | |
# Set the registry value to disable Widgets | |
Set-ItemProperty -Path $registryPath -Name $valueName -Value $value | |
# Restart Explorer to apply changes | |
Stop-Process -Name explorer -Force | |
} | |
function speedtest { | |
$speedTestResult = speedtest --format=json | |
$speedTestResultObj = $speedTestResult | ConvertFrom-Json | |
$downloadSpeedMbps = [math]::round($speedTestResultObj.download.bandwidth / 125000, 2) # Convert to Mbps | |
$uploadSpeedMbps = [math]::round($speedTestResultObj.upload.bandwidth / 125000, 2) # Convert to Mbps | |
$pingMs = $speedTestResultObj.ping.latency | |
Write-Host "Download Speed: $downloadSpeedMbps Mbps" | |
Write-Host "Upload Speed: $uploadSpeedMbps Mbps" | |
Write-Host "Ping: $pingMs ms" | |
} | |
# Call the function | |
#Disable-NewsAndInterests | |
function Disable-EdgeSearch { | |
# Set registry paths for disabling Bing search and Cortana web integration | |
$registryPath = "HKCU:\Software\Policies\Microsoft\Windows\Explorer" | |
$registryPath2 = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" | |
# Check if the key exists, if not, create it | |
if (-not (Test-Path $registryPath)) { | |
New-Item -Path $registryPath -Force | |
} | |
if (-not (Test-Path $registryPath2)) { | |
New-Item -Path $registryPath2 -Force | |
} | |
# Disable web search and Cortana | |
Set-ItemProperty -Path $registryPath -Name "DisableSearchBoxSuggestions" -Value 1 -Type DWord | |
Set-ItemProperty -Path $registryPath2 -Name "BingSearchEnabled" -Value 0 -Type DWord | |
Set-ItemProperty -Path $registryPath2 -Name "CortanaConsent" -Value 0 -Type DWord | |
# Restart Explorer to apply changes | |
Stop-Process -Name explorer -Force | |
} | |
# Call the function | |
#Disable-EdgeSearch | |
function gh { | |
cd $EVN:USERPROFILE\\Documents\\GitHub\\ | |
} | |
function btop { | |
btop4win | |
} | |
function reboot { | |
Restart-Computer | |
} | |
# Function to disable the Caps Lock key | |
function Disable-CapsLock { | |
$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout" | |
$scancodeMapName = "Scancode Map" | |
# Check if the key exists | |
if (-not (Test-Path $registryPath)) { | |
Write-Host "Registry path does not exist." | |
return | |
} | |
# Create the scancode map binary value to disable Caps Lock | |
$scancodeMap = [byte[]]( | |
0x00, 0x00, 0x00, 0x00, # Header | |
0x00, 0x00, 0x00, 0x00, # Header | |
0x02, 0x00, 0x00, 0x00, # Entries (one remap) | |
0x00, 0x00, 0x3A, 0x00, # Disable Caps Lock (Scancode for CapsLock = 0x3A) | |
0x00, 0x00, 0x00, 0x00 # End of the map | |
) | |
# Set the registry key to disable Caps Lock | |
Set-ItemProperty -Path $registryPath -Name $scancodeMapName -Value $scancodeMap | |
Write-Host "Caps Lock key has been disabled. Please restart your system for the change to take effect." | |
} | |
function Remap-CapsLock-To-Tab { | |
$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout" | |
$scancodeMapName = "Scancode Map" | |
# Check if the key exists | |
if (-not (Test-Path $registryPath)) { | |
Write-Host "Registry path does not exist." | |
return | |
} | |
# Create the scancode map binary value to remap Caps Lock to Tab | |
$scancodeMap = [byte[]]( | |
0x00, 0x00, 0x00, 0x00, # Header | |
0x00, 0x00, 0x00, 0x00, # Header | |
0x02, 0x00, 0x00, 0x00, # Number of entries (one remap) | |
0x0F, 0x00, 0x3A, 0x00, # Remap Caps Lock (0x3A) to Tab (0x0F) | |
0x00, 0x00, 0x00, 0x00 # End of the map | |
) | |
# Set the registry key to remap Caps Lock to Tab | |
Set-ItemProperty -Path $registryPath -Name $scancodeMapName -Value $scancodeMap | |
Write-Host "Caps Lock key has been remapped to Tab. Please restart your system for the change to take effect." | |
} | |
# Run the function | |
#Remap-CapsLock-To-Tab | |
# Call the function to disable Caps Lock | |
# Disable-CapsLock | |
function easyeda { | |
param ( | |
[string]$OutputPath = 'X:\Dropbox\Kicad\test' | |
) | |
# Function to get the clipboard text | |
function Get-ClipboardText { | |
Add-Type -AssemblyName PresentationCore | |
return [Windows.Clipboard]::GetText() | |
} | |
# Get clipboard text | |
$clipboardText = Get-ClipboardText | |
# Define regex pattern for part number: C followed by up to 8 digits | |
$pattern = "^C\d{1,8}$" | |
# Check if clipboard contains a valid part number | |
if ($clipboardText -match $pattern) { | |
$partNumber = $clipboardText | |
Write-Host "Found valid part number in clipboard: $partNumber" | |
} else { | |
# Prompt user for part number if clipboard doesn't have a valid value | |
$partNumber = Read-Host "Clipboard does not contain a valid part number. Please enter the LCSC part number (e.g., C1848578)" | |
} | |
# Construct the command using the part number | |
$command = "easyeda2kicad.exe --lcsc_id $partNumber --full --output '$OutputPath'" | |
# Run the command | |
Invoke-Expression $command | |
# Inform the user that the conversion is complete | |
Write-Host "Conversion complete. Output saved to $OutputPath" | |
} | |
# Import the Chocolatey Profile that contains the necessary code to enable | |
# tab-completions to function for `choco`. | |
# Be aware that if you are missing these lines from your profile, tab completion | |
# for `choco` will not function. | |
# See https://ch0.co/tab-completion for details. | |
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
if (Test-Path($ChocolateyProfile)) { | |
Import-Module "$ChocolateyProfile" | |
} | |
function tail { | |
param ( | |
[string]$FilePath, | |
[int]$Lines = 10 # Default to the last 10 lines | |
) | |
# Check if the file exists | |
if (-not (Test-Path $FilePath)) { | |
Write-Host "File not found: $FilePath" -ForegroundColor Red | |
return | |
} | |
# Get the total number of lines in the file | |
$totalLines = (Get-Content -Path $FilePath).Count | |
# Calculate the starting line (total lines - lines to display) | |
$startLine = $totalLines - $Lines | |
if ($startLine -lt 0) { $startLine = 0 } # Ensure we don't have negative start | |
# Output the last $Lines lines from the file | |
Get-Content -Path $FilePath | Select-Object -Skip $startLine | |
} | |
function which { | |
param ( | |
[string]$CommandName | |
) | |
# Check if the command is a path (relative or absolute) | |
if (Test-Path $CommandName) { | |
Write-Output (Get-Item $CommandName).FullName | |
return | |
} | |
# Split the PATH environment variable into an array of directories, ignoring empty ones | |
$pathDirs = $env:PATH -split ';' | Where-Object { $_ -ne "" } | |
# Check each directory for the command | |
foreach ($dir in $pathDirs) { | |
$filePath = Join-Path -Path $dir -ChildPath $CommandName | |
# Check for an exact match, or with common executable extensions | |
if (Test-Path $filePath) { | |
Write-Output $filePath | |
return | |
} | |
# On Windows, check for common executable extensions | |
foreach ($ext in ".exe", ".bat", ".cmd", ".ps1") { | |
$extendedPath = "$filePath$ext" | |
if (Test-Path $extendedPath) { | |
Write-Output $extendedPath | |
return | |
} | |
} | |
} | |
# If no match was found | |
Write-Host "${CommandName}: command not found" -ForegroundColor Red | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment