Skip to content

Instantly share code, notes, and snippets.

@dzogrim
dzogrim / git-done.sh
Created October 16, 2026 13:14
clean up after a merged pull request
#!/usr/bin/env bash
#
# git-done: clean up after a merged pull request.
#
# Fetches the upstream remote with prune, proves the current branch is merged,
# switches to the remote default branch, fast-forwards it, and deletes the
# branch. Every guardrail runs before the first state change, so an abort
# leaves the repository exactly as it was (apart from remote-tracking refs).
#
# Usage: git done [-n|--dry-run] [--no-gh] [-h|--help]
@dzogrim
dzogrim / rename-by-creation-date
Last active September 27, 2026 14:04
Rename files according to their filesystem creation (birth) date
#!/usr/bin/env bash
# shellcheck shell=bash
#
# ==============================================================================
# rename-by-creation-date
# ==============================================================================
#
# Description:
# Rename files according to their filesystem creation (birth) date.
#
@dzogrim
dzogrim / nix-plist-manager-mac
Last active September 26, 2026 08:37
Standalone macOS settings helper for nix-plist-manager
#!/usr/bin/env bash
# shellcheck shell=bash
#
# ==============================================================================
# nix-plist-manager-mac
# ==============================================================================
#
# Description: Standalone macOS settings helper for nix-plist-manager.
#
# Provides a simple operational interface to:
@dzogrim
dzogrim / truncate-long-filenames.sh
Last active August 29, 2026 14:06
Safely shorten overly long filenames while preserving extensions
#!/usr/bin/env bash
set -Eeuo pipefail
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2026 dzogrim
# SPDX-FileContributor: dzogrim <dzogrim@dzogrim.pw>
# ---------------------------------------------------------------------------
# File: truncate-long-filenames.sh
# Purpose:
# Safely shorten overly long filenames while preserving extensions.
@dzogrim
dzogrim / git-reset-history.sh
Created August 14, 2026 12:16
Safely collapse an entire git history into a single commit using an orphan branch, then force-push the result to the remote.
#!/usr/bin/env bash
#
# git-reset-history.sh
#
# Safely collapse an entire git history into a single commit using an
# orphan branch, then (optionally) force-push the result to the remote.
#
# Design goals:
# * Works on macOS (stock bash 3.2) and Linux. No GNU-only flags.
# * Does not rely on the user's git configuration (pager, color, aliases).
@dzogrim
dzogrim / pve-hotplug-remediate.sh
Created August 12, 2026 08:35
Inventory PVE guests that are NOT ready for on-the-fly resource hotplug
#!/usr/bin/env bash
#
# pve-hotplug-remediate.sh
#
# Inventory PVE guests that are NOT ready for on-the-fly resource hotplug
# (vCPU / RAM / disk / NIC), and optionally pre-stage the fix as *pending*
# config changes (the orange values in the web UI), applied at next cold boot.
#
# DRY RUN IS THE DEFAULT. Nothing is written without --apply.
#
@dzogrim
dzogrim / convert-finder-aliases.sh
Created August 4, 2026 14:59
Safely converts macOS Finder alias files below ROOT into POSIX symlinks
#!/usr/bin/env bash
#
# convert-finder-aliases.sh
# ---------------------------------------------------------------------------
# Safely converts macOS Finder alias files below ROOT into POSIX symlinks.
#
# Internal aliases, whose targets are inside ROOT, are converted to relative
# symlinks so the complete tree can be moved or mounted elsewhere. External
# aliases are reported by default and can be converted to absolute symlinks only
# with --apply --include-external.
@dzogrim
dzogrim / findHD_videos.sh
Created July 26, 2026 16:59
findHD_videos.sh - published from local Scripts source of truth
#!/usr/bin/env bash
# ==============================================================================
# Script : findHD_videos.sh
# Description : Recursively scans the current directory for supported media
# files, inspects their video properties with MPlayer, and creates
# symbolic links for files that meet the configured HD criteria.
#
# Videos wider than the minimum resolution are classified into
# two output directories:
@dzogrim
dzogrim / folderizeFolders.sh
Created July 26, 2026 16:59
folderizeFolders.sh - published from local Scripts source of truth
#!/usr/bin/env bash
# ==============================================================================
# Script : folderizeFolders.sh
# Description : Reorganizes the immediate subdirectories of the current working
# directory by moving each one into a companion directory whose
# name is suffixed with an underscore.
#
# Example:
#
@dzogrim
dzogrim / tiff2jpeg
Created July 26, 2026 15:02
tiff2jpeg - published from local Scripts source of truth
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
#
# Script : tiff2jpeg
# Description :
# Converts every TIFF image in the current directory to JPEG using
# ImageMagick, then moves each successfully converted source file to
# the current user's Trash directory.
#
# Input files are processed from the current working directory and matched