From 10ef66725c60d88a7fced1dda7302daa8f21521d Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 12 Jun 2021 19:13:41 -0300 Subject: scripts/commit-md: Add initial version --- scripts/commit-md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 scripts/commit-md (limited to 'scripts/commit-md') diff --git a/scripts/commit-md b/scripts/commit-md new file mode 100755 index 00000000..91610b6d --- /dev/null +++ b/scripts/commit-md @@ -0,0 +1,26 @@ +#!/bin/sh +set -eu + +LAST_COMMIT="$(git rev-parse HEAD)" +COMMIT="${1:-$LAST_COMMIT}" +REPOSITORY="$(basename "$PWD")" + +usage() { + cat <&2 + exit 2 +fi + +LINK="$(printf 'https://git.euandreh.xyz/%s/commit/?id=%s' "$REPOSITORY" "$COMMIT")" +MD="$(printf '[`%s`](%s)' "$COMMIT" "$LINK")" + +xdg-open "$LINK" +printf '%s' "$MD" | xclip -sel clip +printf 'Copied %s to the clipboard!\n' "$MD" >&2 -- cgit v1.3