Updated mygit-date to accept hour+minute, assume current day + random seconds.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Thu, 29 Nov 2018 00:00:11 +0200
changeset 909 a2940bea3a6d
parent 908 e69cc87ded5d
child 910 60635dc58066
Updated mygit-date to accept hour+minute, assume current day + random seconds.
.bashrc
--- a/.bashrc	Tue Oct 16 08:43:53 2018 +0300
+++ b/.bashrc	Thu Nov 29 00:00:11 2018 +0200
@@ -250,7 +250,16 @@
   ag --nofilename --count -- "$1" | awk '{c += $1} END {print c}'
 }
 
+# "YYYY-MM-DD hh:mm:ss" or "hh:mm" for current day and random sec.
 mygit-date() {
+  if [[ "02:23" =~ ^[0-9]{2}:[0-9]{2}$ ]]; then
+      local sec=$(($RANDOM % 60))
+      if [[ ${#sec} = 1 ]]; then
+          sec=0$sec
+      fi
+      local yyyymmdd=`date +%F`
+      set "$yyyymmdd $1:$sec"
+  fi
   echo GIT_COMMITTER_DATE='"'"$1"'"' git commit --amend --no-edit --date '"'"$1"'"'
   GIT_COMMITTER_DATE="$1" git commit --amend --no-edit --date "$1"
 }