[PATCH 1/3] g: rtfm: clean up sed expression
Export this patch
---
bin/g | 2 + -
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bin/g b/bin/g
index cd9e083..6766c48 100755
--- a/bin/g
@@ -30,7 +30,7 @@ case "$CMD" in
"pf") CMD="push -f" ;;
"r") CMD="rm" ;;
"rc") CMD="rm --cached" ;;
- "rtfm") exec man $(find /usr/share/man -name "git-*" | sed "s/.*\///;s/\..*//" | shuf -n1) ;;
+ "rtfm") exec man $(find /usr/share/man -name "git-*" | sed -e 's:.*/::' -e 's/\..*//' | shuf -n1) ;;
"s") CMD="status" ;;
"se") export GIT_EDITOR="$EDITOR" CMD="send-email" ;;
"sl") CMD="shortlog" ;;
--
2.33.0
---
bin/g | 2 + -
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bin/g b/bin/g
index 6766c48..12879b9 100755
--- a/bin/g
@@ -30,7 +30,7 @@ case "$CMD" in
"pf") CMD="push -f" ;;
"r") CMD="rm" ;;
"rc") CMD="rm --cached" ;;
- "rtfm") exec man $(find /usr/share/man -name "git-*" | sed -e 's:.*/::' -e 's/\..*//' | shuf -n1) ;;
+ "rtfm") exec man "$(find /usr/share/man -name "git-*" | sed -e 's:.*/::' -e 's/\..*//' | shuf -n1)" ;;
"s") CMD="status" ;;
"se") export GIT_EDITOR="$EDITOR" CMD="send-email" ;;
"sl") CMD="shortlog" ;;
--
2.33.0
[PATCH 3/3] g: rtfm: posix compliance
Export this patch
---
bin/g | 5 ++++ -
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bin/g b/bin/g
index 12879b9..387962e 100755
--- a/bin/g
@@ -30,7 +30,10 @@ case "$CMD" in
"pf") CMD="push -f" ;;
"r") CMD="rm" ;;
"rc") CMD="rm --cached" ;;
- "rtfm") exec man "$(find /usr/share/man -name "git-*" | sed -e 's:.*/::' -e 's/\..*//' | shuf -n1)" ;;
+ "rtfm") exec man "$(find /usr/share/man -name "git-*" |
+ sed -e 's:.*/::' -e 's/\..*//' |
+ awk 'BEGIN{srand()}{print rand() * 1000000 "\t" $0}' |
+ sort -n | head -n1 | cut -f2-)" ;;
Once we're bringing awk in, let's drop the sed in favor of sub(). We
also don't need the second sed expr - not sure why I had it in the first
place.
In addition, please add a space between the BEGIN block and the second
block.
"s") CMD="status" ;;
"se") export GIT_EDITOR="$EDITOR" CMD="send-email" ;;
"sl") CMD="shortlog" ;;
--
2.33.0
Quick note: since this list is used for more than just my dotfiles,
please set format.subjectPrefix to 'PATCH dotfiles'. Thanks!