Skip to content

Instantly share code, notes, and snippets.

@Windos
Created April 2, 2025 18:45
Show Gist options
  • Save Windos/12c73b7abb7bb8196d7cb1b7323c28c8 to your computer and use it in GitHub Desktop.
Save Windos/12c73b7abb7bb8196d7cb1b7323c28c8 to your computer and use it in GitHub Desktop.
windos-profile.ps1
$env:difftool = 'C:\ProgramData\chocolatey\bin\meld.exe'
if ($env:TERM_PROGRAM -eq 'VSCode' -or $env:WT_SESSION) {
if ($psedition -eq 'core') {
$ansiesc = "`e"
} else {
$ansiesc = [char]0x1b
}
Set-PSReadlineOption -Colors @{
Command = "$($ansiesc)[93m"
Comment = "$($ansiesc)[32m"
ContinuationPrompt = "$($ansiesc)[37m"
Default = "$($ansiesc)[37m"
Emphasis = "$($ansiesc)[96m"
Error = "$($ansiesc)[31m"
Keyword = "$($ansiesc)[35m"
Member = "$($ansiesc)[96m"
Number = "$($ansiesc)[35m"
Operator = "$($ansiesc)[37m"
Parameter = "$($ansiesc)[37m"
Selection = "$($ansiesc)[37;46m"
String = "$($ansiesc)[33m"
Type = "$($ansiesc)[34m"
Variable = "$($ansiesc)[96m"
}
#Verbose Text should be distinguishable, some hosts set this to yellow
$host.PrivateData.ErrorForegroundColor = 'Red'
$host.PrivateData.VerboseForegroundColor = 'Cyan'
$host.PrivateData.WarningForegroundColor = 'Yellow'
$host.PrivateData.DebugForegroundColor = 'Magenta'
$host.PrivateData.ProgressForegroundColor = 'Yellow'
$host.PrivateData.ProgressBackgroundColor = 'DarkCyan'
}
if ([bool]($env:WT_SESSION)) {
oh-my-posh init pwsh --config "C:\Users\Windos\.config\oh-my-posh\kali-custom.omp.json" | Invoke-Expression
$env:POSH_GIT_ENABLED = $true
}
function Expand-Object {
[cmdletBinding()]
Param(
[Parameter(Mandatory,
Position = 0)]
[string] $ExpandProperty,
[Parameter(ValueFromPipeline)]
[psobject] $InputObject
)
Begin {}
Process {
foreach ($Object in $InputObject) {
Select-Object -InputObject $Object -ExpandProperty $ExpandProperty
}
}
End {}
}
New-Alias -Name expand -Value Expand-Object
function Get-WindosGeoLocationData {
[CmdletBinding()]
Param(
[Parameter(Mandatory,
Position = 0)]
[IPAddress[]] $IPAddress
)
foreach ($IP in $IPAddress) {
$uri = "https://api.ipdata.co/{0}?api-key={1}&fields=ip,country_name,organisation,asn,'" -f $IP, (Get-Secret -Name 'GeoLocationApiKey')
$IPData = Invoke-RestMethod -method Get -UseBasicParsing -Uri $uri
$ReturnData = [PSCustomObject] [Ordered] @{
IP = $IPData.ip
Country = $IPData.country_name
Organisation = $IPData.organisation
ASN = $IPData.asn.asn
Name = $IPData.asn.name
Domain = $IPData.asn.domain
Route = $IPData.asn.route
Type = $IPData.asn.type
}
$ReturnData
}
}
New-Alias -Name geo -Value Get-WindosGeoLocationData
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
Invoke-Expression (& { (zoxide init powershell | Out-String) })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment