penguin/utils

my env utils

commit b420add084fc47a1bc377be4afba95722593595f

author斟酌 鵬兄 <tgckpg@gmail.com>
date2022-08-11T15:24:41Z
subjectAdded git-utils
commit b420add084fc47a1bc377be4afba95722593595f
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2022-08-11T15:24:41Z

    Added git-utils
---
 bash/bashrc/sources/12_shortcuts | 16 ++++------------
 bash/bashrc/sources/21_win-greps | 12 ++++++++++++
 bash/bashrc/sources/31_git-utils | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/bash/bashrc/sources/12_shortcuts b/bash/bashrc/sources/12_shortcuts
index a1f74a3..0b90369 100755
--- a/bash/bashrc/sources/12_shortcuts
+++ b/bash/bashrc/sources/12_shortcuts
@@ -1,17 +1,9 @@
 #!/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>\""
+function sanitize-perms {
+    chown $USER.$USER . -R
+    find . -type d -exec chmod 755 {}\;
+    find . -type f -exec chmod 644 {}\;
 }
 
 # Kubernetes
diff --git a/bash/bashrc/sources/21_win-greps b/bash/bashrc/sources/21_win-greps
new file mode 100755
index 0000000..4c1aa3d
--- /dev/null
+++ b/bash/bashrc/sources/21_win-greps
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+function grepo {
+    grep --color=always "$1" . -r | awk '{ count++; print "      ["count"] "$0 } '
+    echo -n "Select number to open: "
+    read num
+
+    IFS="
+"
+    CHOICES=( `grep -n "$1" . -r | awk 'BEGIN{ FS=":" }{ print "notepad /g "$2" "$1 }'` )
+    bash -c ${CHOICES[$(( num - 1 ))]}
+}
diff --git a/bash/bashrc/sources/31_git-utils b/bash/bashrc/sources/31_git-utils
new file mode 100644
index 0000000..a8779ac
--- /dev/null
+++ b/bash/bashrc/sources/31_git-utils
@@ -0,0 +1,32 @@
+#!/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>\""
+}
+
+
+if [ -f "$HOME/.gitconfig" ]; then
+    cat << ___CONF___ > "$HOME/.gitconfig"
+[alias]
+    la = log --graph --full-history --date-order --all --pretty=format:'%Cred%h%Creset %ad %C(bold blue)[%an]%Creset | %C(white)%s%Creset %C(yellow)%d%Creset' --date=relative
+
+[color]
+    ui = auto
+[core]
+    excludesfile = ~/gitignore
+[push]
+    default = tracking
+[credential]
+	helper = store
+___CONF___
+fi