Skip to content

Instantly share code, notes, and snippets.

@garthk
garthk / apple-load-keychain.plugin.zsh
Created August 29, 2024 08:02
ZSH plugin to load SSH keys from your macOS keychain
if [[ -o login && -o interactive ]]; then
ssh-add -q --apple-load-keychain
fi
@garthk
garthk / layout_python_hatch.sh
Created August 30, 2024 11:46
layout_python_hatch: direnv config plugin for python projects using hatch
# shellcheck shell=sh enable=all
# ~/.config/direnv/lib/layout_python_hatch.sh
# direnv config plugin for hatch
# https://direnv.net
fail() {
[ "$#" != "0" ] || set -- FAIL
echo >&2 "$@"
return 1
}
@garthk
garthk / annotations.py
Last active September 3, 2024 07:01
Remove annotations from scripts so they work on Python 3.6
from __future__ import annotations
import ast
import sys
from pathlib import Path
__all__ = ["remove_annotations"]
class AnnotationRemovalTransformer(ast.NodeTransformer):
@garthk
garthk / git-tmutil-ignore.bash
Created June 6, 2025 06:59
Tell macOS' Time Machine to ignore the files Git ignores
#!/bin/bash
# shellcheck enable=all disable=SC2030,SC2249,SC2250
function git-tmutil-ignore() (
set -euo pipefail
case $=${ZSH_NAME-${BASH-other}} in
*/bash) shopt -s lastpipe ;;
esac
attr_name=com.apple.metadata:com_apple_backup_excludeItem
attr_value=bplist00_com.apple.backupd