aboutsummaryrefslogtreecommitdiff
path: root/scripts/commit-md
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-06-12 19:13:41 -0300
committerEuAndreh <eu@euandre.org>2021-06-12 19:13:41 -0300
commit10ef66725c60d88a7fced1dda7302daa8f21521d (patch)
tree4bb9436d9e0aff193fb360bbbcda1ef30b6cf876 /scripts/commit-md
parentscripts/git-permalink: Make it a symlink to the project that was promoted fro... (diff)
downloaddotfiles-10ef66725c60d88a7fced1dda7302daa8f21521d.tar.gz
dotfiles-10ef66725c60d88a7fced1dda7302daa8f21521d.tar.xz
scripts/commit-md: Add initial version
Diffstat (limited to '')
-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