From 744bfc948f71ea037654443f6678aa0170bf9c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Tue, 9 Aug 2022 14:48:36 +0800 Subject: [PATCH] Added git-config-as --- bash/bashrc/rbashrc | 1 + bash/bashrc/sources/12_shortcuts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100755 bash/bashrc/sources/12_shortcuts 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>\"" +} +