Skip to content

Instantly share code, notes, and snippets.

View jdharmon's full-sized avatar

Jason Harmon jdharmon

  • PROSOFT
  • Virginia Beach, VA
View GitHub Profile
@jdharmon
jdharmon / posh-git.zsh-theme
Last active January 26, 2025 13:09
Oh My Zsh theme that mimics the behavior of posh-git
# Colors
local RED="%F{red}"
local GREEN="%F{green}"
local BLUE="%F{blue}"
local YELLOW="%F{yellow}"
local MAGENTA="%F{magenta}"
local CYAN="%F{cyan}"
local RESET="%f"
# Symbols
@jdharmon
jdharmon / Git-Prompt.ps1
Last active April 2, 2025 18:21
One-page PowerShell Git Prompt. Alternative to posh-git.
# Add to PowerShell $PROFILE
function Get-GitPrompt {
$inGitRepo = [bool](git rev-parse --is-inside-work-tree 2>$null)
if (-not $inGitRepo) {
return
}
$branch = git branch --show-current
$status = git status --short --branch
function Set-WorkingDirectory($Path) {
if (-not $Path) {
$Path = "~"
}
if ((Resolve-Path $Path).Provider.Name -eq 'FileSystem') {
[System.IO.Directory]::SetCurrentDirectory($Path)
}
Set-Location $Path
}
private static void WaitForExitSignal()
{
using (var signal = new ManualResetEventSlim())
{
// Handle SIGTERM
AssemblyLoadContext.Default.Unloading += _ => signal.Set();
// Hadle SIGINT/Ctrl+C
Console.CancelKeyPress += (s, a) =>
{
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.IO;
using System.Runtime.Loader;
using System.Threading;
using System.Threading.Tasks;
namespace MyApp
@jdharmon
jdharmon / PSCommandCompletion.ps1
Last active November 28, 2023 21:07
PowerShell Kubectl & Helm Command Completion
# Setup
Install-Module -Name PSBashCompletions -Scope CurrentUser
$path = (mkdir (Join-Path (Split-Path -Parent $PROFILE) Completion)).FullName
((kubectl completion bash) -join "`n") | Set-Content -Encoding ASCII -NoNewline -Path $path/kubectl.sh
((helm completion bash) -join "`n") | Set-Content -Encoding ASCII -NoNewline -Path $path/helm.sh
# Profile
$completionPath = Join-Path (Split-Path -Parent $PROFILE) Completion
if (Test-Path $completionPath) {
Import-Module PSBashCompletions
@jdharmon
jdharmon / Watch-Command.ps1
Last active July 27, 2020 14:11
PowerShell watch
function Watch-Command {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline, Mandatory)]
[object]
$ScriptBlock,
[int]
$Seconds = 2
)
@jdharmon
jdharmon / Join-Url.ps1
Created February 12, 2019 18:56
PowerShell Join-Url
function Join-Url([string[]]$parts) {
return ($parts | % { $_.Trim('/') } | ? { $_ }) -join '/'
}
@jdharmon
jdharmon / keybase.md
Created August 3, 2017 01:33
Keybase proof

Keybase proof

I hereby claim:

  • I am jdharmon on github.
  • I am jdharmon (https://keybase.io/jdharmon) on keybase.
  • I have a public key ASBIYp-yt0-x9vJQnTTbLnqCkNJFcQqyv5jBoCzvG1_IZwo

To claim this, I am signing this object: