aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/commit-md26
1 files changed, 26 insertions, 0 deletions
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 <<EOF
+Usage:
+ $0 [COMMIT]
+EOF
+}
+
+if [ -z "$COMMIT" ]; then
+ echo "Missing \$COMMIT argument"
+ usage >&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