get the last commit hash in abbreviated form
git log -n1 --pretty=format:%h
list files in another branch
git ls-files --with-tree=another-branch
#!/bin/bash | |
dmg_path="$1" | |
# use process redirection to capture the mount point and dev entry | |
IFS=$'\n' read -rd '\n' mount_point dev_entry < <( | |
# mount the diskimage (leave out -readonly if making changes to the file system) | |
hdiutil attach -readonly -plist "$dmg_path" | \ |
#!/bin/bash | |
agree() { | |
local question="$1" | |
while true; do | |
read -p "$question " answer | |
case $answer in | |
[Yy]|[Yy][Ee][Ss]) return 0 ;; | |
[Nn]|[Nn][Oo]|'') return 1 ;; # empty string is default |
#!/bin/sh | |
# create remote origin and push | |
# use 'trunk' unless init.defaultBranch is set | |
default_branch=$(git config init.defaultBranch || echo 'trunk') | |
remote_host='your-remote-host' | |
# assuming the remote host has a directory in $HOME named git | |
toplevel=$(git rev-parse --show-toplevel) | |
remote_repo_path="git/${toplevel##*/}.git" |
#!/usr/bin/env bash | |
split() { | |
local IFS="$1" | |
shift | |
set -- $* | |
echo "$@" | |
} | |
join() { |
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Getopt::Long; | |
use Digest::MD5; | |
#use diagnostics; | |
my $minimum = 0; | |
my $header = ''; |
The shell used in the following examples is bash, but the commands can be adapted for other shells.
The goal here is to have a performant way to determine if we are in a git repo without printing anything.
git status --porcelain --untracked-files=no &>/dev/null && \
#!/usr/bin/env awk -f | |
BEGIN { | |
FS = ":" | |
RS = "\r\n" | |
OFS = "\t" | |
} | |
/BEGIN:VTODO/ { | |
my_status = "" |