.bashrc
changeset 909 a2940bea3a6d
parent 901 5e5c705d2831
child 915 691db6af02e4
--- 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"
 }