I use these snippets in my blogs at www.LifeWithAlacrity.com and www.BlockchainCommmons.com.
-
Abstract: This guide provides best practices for writing clear, maintainable, and robust Zsh scripts. Aimed at helping developers transition from Bash to Zsh, particularly on macOS, this guide offers practical advice and examples for creating standardized and efficient scripts.
-
Copyright This text of this guide is Copyright ©️2024 by Christopher Allen, and is shared under spdx:CC-BY-SA-4.0 open-source license. All the example code is relenquished to the public domain under spx:CC0-1.0.
-
Tags: #zsh #scripting #cli #opinionated
First pass of organizing various data and scripts about a repository. One open question is seperation of data about a repository vs scripts that use that data.
Note that much of this doesn't currently work with various Git hosting services (for instance GitHub & GitLab put their files in .github/
.gitlab/
respectively). Instead, this is more of a proposal.
Git itself uses .git/hooks
. but you can set git config core.hooksPath /path/to/your/hooks
to the path you want.
Git started supporting SHA-256 based commit hashes in version 2.29, officially released on October 19, 2020.
This version included the --object-format=sha256
option for the git init
command.
This feature is part of Git's ongoing efforts to enhance security and address potential vulnerabilities related to the use of SHA-1 hash algorithm.
The GIT_COMMITTER_IDENT
and GIT_AUTHOR_IDENT
environment variables allow you to set detailed author and committer information for a git commit
in a single environment variable. These variables give you finer control over the identity information attached to commits, which can be particularly useful in automated systems or scripts that manage multiple git operations, or when you need to override both the name, email, and date simultaneously without setting each component individually.
It's worth noting that these variables are less commonly used and are not as well-documented as the individual GIT_AUTHOR_NAME
, GIT_AUTHOR_EMAIL
, GIT_COMMITTER_NAME
, and GIT_COMMITTER_EMAIL
variables.
# Remove any old git relics — we are creating an empty commit for a new identifier | |
rm -rf ./.git | |
git init # --object-format=sha256 | |
# INCEPTION_CREATOR_NICK="any-nickname" | |
# This gets your your GitHub nick from your `gh` cli files if you have them |
#!/bin/zsh | |
# ./self-signed-ssh.sh <path_to_ssh_public_key> | |
# Script to sign an SSH public key and verify the signature | |
# Check if the script is called with the necessary public key path argument | |
# Parameters: | |
# $1 - Path to the SSH public key. | |
function check_arguments { | |
if [[ -z "$1" ]]; then | |
echo "Usage: $0 <path_to_ssh_public_key>" |