penguin/utils

my env utils

commit 744bfc948f71ea037654443f6678aa0170bf9c3b

author斟酌 鵬兄 <tgckpg@gmail.com>
date2022-08-09T06:48:36Z
subjectAdded git-config-as
commit 744bfc948f71ea037654443f6678aa0170bf9c3b
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2022-08-09T06:48:36Z

    Added git-config-as
---
 bash/bashrc/rbashrc              |  1 +
 bash/bashrc/sources/12_shortcuts | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/bash/bashrc/rbashrc b/bash/bashrc/rbashrc
index efd85c6..4ca6df8 100644
--- a/bash/bashrc/rbashrc
+++ b/bash/bashrc/rbashrc
@@ -211,6 +211,7 @@ function __ns {
 
 __ns "package.sh" 1
 __ns "10_aliases"
+__ns "12_shortcuts"
 __ns "20_fast-greps"
 __ns "30_mysql"
 __ns "40_go-command"
diff --git a/bash/bashrc/sources/12_shortcuts b/bash/bashrc/sources/12_shortcuts
new file mode 100755
index 0000000..0767d74
--- /dev/null
+++ b/bash/bashrc/sources/12_shortcuts
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+function git-config-as {
+	local SHA NAME EMAIL
+	SHA=$1
+	if [ -z "$1" ]; then
+		SHA=HEAD
+	fi
+	NAME=$( git log $SHA -1 --pretty=format:%aN )
+	EMAIL=$( git log $SHA -1 --pretty=format:%ae )
+
+	git config user.name "$NAME"
+	git config user.email "$EMAIL"
+	echo "Configured as \"$NAME <$EMAIL>\""
+}
+