dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | README | LICENSE

commit 3a78a1b00ab5d3422bcdf3ce25b3f8d7b8a962fb (patch)
parent cd337bf3d48f5132a513f092bb68b21570e8d660
Author: Alex Karle <alex@alexkarle.com>
Date:   Sun, 20 Feb 2022 14:45:59 -0500

bin: Add `changed` and `rmake`, 2 commonly used utils

I've been using these at work frequently, where it's common to
have the master branch move ahead of my topic branch and I frequently
work in a sub-directory of the directory containing the Makefile.

They're nothing super special, just small QoL wins :)

Diffstat:
Abin/changed | 16++++++++++++++++
Abin/rmake | 11+++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/bin/changed b/bin/changed @@ -0,0 +1,16 @@ +#!/bin/sh +# changed -- diff against the merge-base +die() { + echo "ERROR: $*" 1>&2 + exit 1 +} + +REPO=$(git rev-parse --show-toplevel 2>/dev/null) +BASE=${BASE:-master} +if [ -n "$REPO" ]; then + MBASE="$(git merge-base origin/$BASE HEAD 2>/dev/null)" + [ -z "$MBASE" ] && die "origin/$BASE doesn't exist; set \$BASE and try again" + git diff "$@" "$MBASE" +else + die "not in a git repo" +fi diff --git a/bin/rmake b/bin/rmake @@ -0,0 +1,11 @@ +#!/bin/sh +# rmake -- make at the repo root +REPO=$(git rev-parse --show-toplevel 2>/dev/null) + +if [ -n "$REPO" ]; then + cd "$REPO" + make "$@" +else + echo "ERROR: not in a git repo" 1>&2 + exit 1 +fi