#!/usr/bin/env bash
set -euo pipefail

if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
  printf "%s" "$(git rev-parse --abbrev-ref HEAD)" | pbcopy
else
  printf '%s\n' "Not a git repository" >&2
  exit 1
fi
