What is causing my terminal zsh script command to hang?

I created a custom zsh script for taking notes of my day and keeping track of the time to make it easier to fill in the temporary sheets. It works great fine, but it just freezes from time to time. It gets registered in the txt file even when it hangs, but does not execute the "say" command.

I think this is a problem with the way I select a random string, but I don't know enough about zsh to fix it.

I am using zsh and this is in my .zshrc file.

createLog() {
  LOGFILE=$HOME/Google\ Drive/autosdls.txt
  # chmod 755 $LOGFILE

  LASTLINE="$(tail -1 $LOGFILE)"
  LASTTIME="$(grep -oE "[[:digit:]]{10}" <<<"$LASTLINE")"
  TIME="$(date +%s)"
  TIMESPENT=$((($TIME-$LASTTIME)/60))
  echo "$TIMESPENT"
  echo "[ ] $TIMESPENT Minutes : $1 |$(date +%s)|" >> $LOGFILE 2>&1


  # Seed random generator
  RANDOM=$$$(date +%s)

  encouragements=("Greatjob!" "Thank you." "Productivity Node Assimilated" "Well done. Your ambition is matched only by your zeal" "Engage" "You're the best! Around! Nothing gonna ever keep you down.")

  selectedexpression=${encouragements[($RANDOM % ${#encouragements[@]})-1]}
  say $selectedexpression
  # echo $selectedexpression
}
alias sdlog=createLog

      

+3


source to share





All Articles