Skip to content

Instantly share code, notes, and snippets.

@wcarroll
Last active December 15, 2019 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wcarroll/d9bfa1174bb04f8203ac02d319fda1c6 to your computer and use it in GitHub Desktop.
Save wcarroll/d9bfa1174bb04f8203ac02d319fda1c6 to your computer and use it in GitHub Desktop.
PowerShell Profile
Function Get-MyIp {
Invoke-RestMethod -Uri "https://ipinfo.io/json"
}
Function Get-LastCommandExecutionTime {
<#
.SYNOPSIS
Gets the execution time of the last command used.
.EXAMPLE
Get-LastCommandExecutionTime
Description
-----------
Gets the last execution time of the last command run.
#>
Process {
if ($(Get-History).Count -gt 0) {
$ts = (Get-History)[-1].EndExecutionTime - (Get-History)[-1].StartExecutionTime
if ($ts.days -gt 0) {
$rtrStr = "[{0}d]" -f [Math]::Round($ts.totalDays, 2)
} elseif ($ts.hours -gt 0) {
$rtrStr = "[{0}h]" -f [Math]::Round($ts.totalHours, 2)
} elseif ($ts.Minutes -gt 0) {
$rtrStr = "[{0}m]" -f [Math]::Round($ts.totalMinuts, 2)
} elseif ($ts.Seconds -gt 0) {
$rtrStr = "[{0}s]" -f [Math]::Round($ts.totalSeconds, 2)
} else {
$rtrStr = "[{0}ms]" -f [Math]::Round($ts.Milliseconds)
}
} else {
$rtrStr = "[0ms]"
}
$rtrStr
}
}
Set-Alias -Name gt -Value Get-LastCommandExecutionTime
<# Import-Module PSColor, posh-git
$GitPromptSettings.DefaultPromptAbbreviateHomeDirectory = $true
$GitPromptSettings.DefaultPromptSuffix = '`nI $([char]0x1b)[0;31m$([char]9829) $([char]0x1b)[0;37mPS> '
$GitPromptSettings.DefaultPromptEnableTiming = $true
#>
function prompt {
return "$(gt) $pwd>"
}
function DoIGiveAFuck {
$Methods = "asshole", "awesome", "bag", "because", "bucket", "bye", "cool", "cup", "diabetes", "everyone", "everything", "family", "fascinating", "flying", "ftfy", "fyyff", "give", "horse", "immensity", "jinglebells", "life", "looking", "maybe", "me", "mornin", "no", "pink", "programmer", "question", "ratarse", "retard", "ridiculous", "rtfm", "sake", "shit", "single", "thanks", "that", "this", "too", "tucker", "what", "zayn", "zero"
$uri = "https://www.foaas.com/{0}/Wes" -f (Get-Random($Methods))
$Headers = @{"accept" = "text/plain" }
Invoke-RestMethod -Uri $uri -Headers $Headers
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment